Trigger Item_code Function


When i fill item_code thought custom script I’m unable to get rate and amount automatically.

frappe.ui.form.on("Sales Order Item",{
	item_code : function (frm, cdt, cdn){
	var d2 = locals[cdt][cdn];{
    	"method": "custom_bom.api.saveBOM",
    	args: {
    		item :d2.item_code,
    		currency :'INR',
    		items : material_popup.get_values().material				
    	freeze: true,
 		freeze_message: __("Loading"),
    	callback: function (r, rt) {
    			d2.item_code= r.item_code
    			d2.qty= r.qty

set item_code with following code.

frappe.model.set_value(cdt, cdn, ‘item_code’,r.message.item_code);

it’ll initiate the change in rate and amount.

and set qty first

d2.qty= r.qty

before setting item_code

I tried it but wasn’t working.

just try,

locals[cdt][cdn][‘field_name’] = value_to_be_enter