Custom script - Updating item description

I have created a doctype in an app where I can save different item description based on language code, which I have added on the Item doctype as a child table. When creating a quote, I am trying to update the item’s description with the one I fetched from my doctype, but it does not work. I can update other fields with my description and it works perfectly, only the description does not want to update…

Here is my custom script:

frappe.ui.form.on(“Quotation Item”, “item_code”, function(frm, cdt, cdn) {
ct = locals[cdt][cdn]
frappe.call({
method: “shei.get_description.fetch_item_description”,
args:{
customer_code: frm.doc.customer,
item_code: ct.item_code,
},
callback: function(r) {
frappe.model.set_value(cdt, cdn, “description”, r.message);
}
})
});

If I do a “msgprint(ct.description);”, I get the correct description, but it never actually shows on the form.

Any help would be greatly appreciated!

Thank you

Bernard

Try to write the code on event other than change of item_code, may be “rate” of item row or “before_save” event of document.

On Item code, there is default js function which is setting up description from item_description, and looks like that’s running after your custom script.

Thank you @Mukesh_Variyani.

I solved it by wrapping the frappe call with frappe.after_ajax(function().

Bernard

1 Like