Currently, for the Delivery Note Item custom script, I have only one line:
msgprint("Test - Delivery Note Item");
I just want to make sure that the script is ever executed. But it seems that the script is never executed. When I click Add New Row in the Delivery Note, nothing happens. It seems that the script is never executed. So I suspect that the form that open when we Click Add New Row is not Delivery Note Item form.
Thank you, but still nothing happens. I think the one line code should work if the form is really a Delivery Note Item. I tried the same exact code in the Delivery Note Form. A dialog pops up as soon as I open a Delivery Note.
item.item_code gives the newly selected item_code. But item.rate is still the previously selected item_rate. How do I get the newly selected item_rate?
This seems like before_update event. Is there anything like after_update event that I can use?
item.price_list_rate does not change on cur_frm.cscript.recalculate() method.
try item.rate field instead. You can find the field names in Customize Form
Go To Customize Form
Select the doctype in `Enter the Form Type* e.g. Delivery Note Item
I think price_list_rate should change because I am changing the item selection say from A to B. So I want to get price_list_rate_B, instead of price_list_rate_A. What I am getting now is price_list_rate_A with item_code_B, even after the refresh and recalculate.
cur_frm.refresh_fields() should be called after recalculate also keep the msgprint() after refresh_fields(). Then only it will show the latest values for all the fields.
Let us say you have a field in Item Doctype custom_field and you want to fetch this in Delivery Note Item.
In Delivery Note Item make a field with the same name custom_field, this does the trick most of the times, if the field names are same, ERPNext will fetch the value. If this is not working for some reason, go to Customize Form for Delivery Note Item, in Fetch from add item_code.custom_field and Save
This will fetch the value from Item Master to Delivery Note Item