Add entries to a doctype table with Javascript?

Hello.

I was trying to create Item Price when creating Item, from master.

I used this custom script to create the item price in the background:

function createItemPrice(rate, item_code, price_list) {
frappe.call({
“method”: “frappe.client.insert”,
“args”: {
“doc”: {“doctype”:“Item Price”,“currency”:“GTQ”,“item_code”:item_code,“price_list”:price_list,“price_list_rate”:rate}
}
});
}

any solution ?