Set Cost Center Value Using Custom Script

Hi ,

I’am trying to set Cost Center value in Sales Invoice Child table.

This is my Script,

var Cuser = frappe.session.user_email; frappe.ui.form.on("Sales Invoice Item", "item_code", function(frm, cdt, cdn) { frappe.call({ method: "frappe.client.get", args: { doctype: "User", filters: {"email":Cuser} }, callback: function(r) { $.each(frm.doc.items || [], function(i, v) { console.log(v.cost_center); frappe.model.set_value(v.doctype, v.name, "cost_center", r.message.default_cost_center); }); } }) });

I fetch the value of “cost_center” from the user doctype I have there custom field “default_cost_center”.

I try Same Script with “warehouse” field it’s working fine but with Cost Center It’s not working.

Any suggestion ?

Thanks & regards