Add multiple values to child table entry

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?

@manasan Try this code:

childTable = frm.add_child("Items");
childTable.item_code = my_item_code;
childTable.description ='This is working';
frm.refresh_field("Items");

the issue with this code is fields like Rate, Amount are not being populated from the database automatically.


Even if I sent those values through code, the fields like Total Quantity, Total (LKR) are not being calculated based on the item details I sent.

Is there a way to refresh those Total calculations?