I want to programmatically add an entry in the Items child table of Quotation with a custom unique description. I tried using the below snippet. When the first set_value executes, it populates all the fields including description with the default values from the DB and the second set_value is executed even before the first one finish executing. So it’s like a flickering effect.
childTable = frm.add_child("items");
frappe.model.set_value(childTable.doctype, childTable.name,'item_code', my_item_code);
frappe.model.set_value(childTable.doctype, childTable.name,'description', 'This is working');
I tried to use then with the returned promise of the first statement but no use.
frappe.model.set_value(childTable.doctype, childTable.name,'item_code', my_item_code)
.then(()=>{
frappe.model.set_value(childTable.doctype, childTable.name,'description', 'This is working');
});
I even tried passing it as an object but still not working
frappe.model.set_value(childTable.doctype, childTable.name,{
'item_code':my_item_code, 'description': 'This is working'
});
I am currently using setTimeout as an alternative but I am sure there must be some better way of doing this. What I am missing here?