Custom script not workin

Hi experts ,

I do have a custom doctype where i need a field’s value to appear in the standard rate field of doctype ‘’ item ‘’ , the source and the destination field have the same field name i made it so so that it would be comfortable , the standard rate field in the custom doctype is made searchable . Now if i enter the item code in the item doctype automatically the standard rate field should get filled . I tried accomplishing that with the following script but it is not working , please help .

`cur_frm.add_fetch(‘quotationmaster’,‘standard_rate’,‘standard_rate’);
{
cur_frm.add_fetch(‘standard_rate’,‘standard_rate’);

frappe.ui.form.on(“Item”, “refresh”, function(frm, doctype, name)
{
cur_frm.get_field(“standard_rate”).get_query = function(doc, cdt, cdn)
{
var item = frappe.get_doc(cdt, cdn);
var c = " ";
if (item.item_code1) c=item.item_code1 ;
return { filters: {‘item_code1’: c}}
}
}); }

What is ‘quotationmaster’? If it’s a custom doctype, you have to choose a particular ‘quotemaster’ document. Also, there is a backtick as your first character, which probably shouldn’t be there.

If you will explain what each of these fields purpose is, I could help you better.

1 Like

Thank you so much sir , actually I am customizing this erpnext for my company which is basically a forging company . Cost estimation involves lot of calculation which we are doing at present in excel so as an improvement I replicated that with python coding in the custom script and it is done under the custom doctype ‘‘quotationmaster’’ , i do have a calculated field called ''standard_rate" i want to import this field’s value to the ‘‘standard_rate’’ field of standard doctype ‘‘item’’ when I enter the item_code in the standard doctype ‘‘item’’ .
The item_code in the ‘‘quotationmaster’’ is linked with the “item_code” in the standard doctype “item” and the required fields are made searchable , the above script is not working whereas i do have a similar script for other items and it works elsewhere Please help

I got the script working . I made a mistake in the script , it is actually

cur_frm.add_fetch(‘item_code’,‘standard_rate’,‘standard_rate’);
{
cur_frm.add_fetch(‘standard_rate’,‘standard_rate’);

frappe.ui.form.on(“Item”, “refresh”, function(frm, doctype, name)
{
cur_frm.get_field(“standard_rate”).get_query = function(doc, cdt, cdn)
{
var item = frappe.get_doc(cdt, cdn);
var c = " ";
if (item.item_code1) c=item.item_code1 ;
return { filters: {‘item_code1’: c}}
}
}); }

This topic was automatically closed after 24 hours. New replies are no longer allowed.