Custom Script get Item Price Rate of Stock Entry Detail Items

Hi.

I need to get the “Standard Selling” Item Price Rate of the item been entered in each Stock Entry Detail item.

Keep in mind that “price_list_rate” is a custom field of “Stock Entry Detail”:

Here is a screenshot of the code so far:

I appreciate anyone who checks the code and helps me find out why it is not working (doesn’t do anything). I am just learning Custom Scripts.

Thanks in Advance

Custom Scripts for Child Tables like Stock Entry Detail should be written in their parent DocType. In this case, you should set Stock Entry as the doctype.

Thanks, @netchampfaris.

I think I am almost done. Here is the code now under the Stock Entry doctype:

frappe.ui.form.on("Stock Entry Detail", 
    { 
        item_code: function(frm, cdt, cdn) 
            { 
		var d = locals[cdt][cdn];
                console.log("Costo : " + d.costo + " y Item Code: " + d.item_code);
                frappe.call(
                    { 
                        method: "frappe.client.get_value",
                        args: { 
                            doctype: "Item Price", 
                            filters: {
                                price_list: "Standard Selling", 
                                item_code: d.item_code
                            },
                            fieldname:["price_list_rate"]
                        },
                        callback: function(r) 
                            { 
                                if(r.message) 
                                    { 
                                        var item_price = r.message; 
					console.log("price_list_rate: " + item_price.price_list_rate);
                                        frm.set_value("price_list_rate", item_price.price_list_rate);
                                    } 
                            }
                    });   
            } 
    }
);

These are the errors and console I get:

This line was the problem. It works if you replace it with:

d.price_list_rate = item_price.price_list_rate;

Hope this helps someone else :slight_smile:

1 Like