Field status change automatically after click on checkbox?

Hello everyone,
I need your help/guidance, In purchase invoice doc i created 1 check box name-custom_received_at_ho and other is bill_receive_date

The thing is i want that once i click/check the checkbox the bill receive date should automatically get the current date filled in it.
It may be done via custom script but i don’t know how to done it.
Any help will be appreciated.

Thank you.

Hi @rs115199789,

Please apply it.

frappe.ui.form.on('Purchase Invoice', {
	custom_received_checkbox: function(frm) {
		frm.set_value('bill_receive_date', frappe.datetime.nowdate());
	}
});

Please check your field name and set it in the script accordingly.

Thank You!

Hi @NCP
I tried but it’s not working, I set the field (bill rec date to read only like the md approval date ) but its not working here is the script.

frappe.ui.form.on(‘Purchase Invoice’, {
received_at_ho_checkbox: function(frm) {
frm.set_value(‘custom_bill_receive_date’, frappe.datetime.nowdate());
}
});

Thanks

Please check the field name.

Already mentioned in the above post.

Hi, @NCP
Above solution Works like charm thank you just one modification is required.
Once i click on the check box it displays the date but when i (untick), it still displays the date, is it possible to remove the date if i untick it ?

Thank you

Please set the if … else condition @rs115199789,

frappe.ui.form.on('Purchase Invoice', {
	received_at_ho: function(frm) {
	    if (frm.doc.received_at_ho) {
		    frm.set_value('bill_receive_date', frappe.datetime.nowdate());
	    } else {
	        frm.set_value('bill_receive_date', '');
	    }
	}
});

Please check your field name and set it in the script accordingly.

Thank You!

1 Like

@NCP
Thanks working perfectly.
you are gem.

Also can you look out for my other post i haven’t found any solution yet.

Thank you for your help :slight_smile:

Hi @rs115199789,

I think, you have to learn some script.

Here are some references:

Thank You!

1 Like

Hi, @NCP
sure i will look into the scripts, but don’t you think it’s an issue with the erp ? as it was working fine in erpnext 13, and also the issue is when we hover the mouse over the workflow it should display submitted but it always says in draft status.

Hi, @NCP

!! Update !!

Your code is working fine, However i just tried to import multiple invoices in which i changed the value of Received at Ho from (0 to 1), which worked as well but the bill receive date didn’t shown up i need to manually click/tick the received at ho checkbox.

Is there any way in which if i update large no. of invoices via data import the date show up automatically if i change the field 0 to 1.
So i don’t have to tick the box one by one.

Thank You