Custom Script Fetch Value From Master

I’m trying to fetch a value from Item into the Sales Order Item. According to this help topic:

I just need to setup a custom script on the Doc Type Sales Order Item of:

add_fetch(link_fieldname, source_fieldname, target_fieldname)

So in my example it’s


But that doesn’t work - my Checkbox field for SOI Size does not get fetched into the Sales Order Item.

In fact if I replicate EXACTLY the example from that help topic above it still doesn’t work.

Has something changed since that custom script example was created?

1 Like


Please ensure Field Type for both source and target field is same, and then

Hi @umair

I have them both set to Check in my Item_code example but I tried exactly as described here

and had both field types as Data and it still didn’t work.

It seems as if this feature either no longer works or the logic in the example is incorrect.

Only for document

cur_frm.cscript.custom_item_code = function(doc, cdt, cdn){
    var child = locals[cdt][cdn];{
        "method": "frappe.client.get_value",
        "args": {
            "doctype": "Item",
            "filters": {
                "name":  child.item_code
        "child": child,
        "fieldname": "soi_size"

Solved fetching the value from the server because add_fetch dont work for fields in grid



The new client script api is better because it allows you to attach multiple handlers

frappe.ui.form.on("Quotation", "item_code", function(frm) { .. });

@rmehta Thanks, I’ll start using it!

@rmehta @max_morais_dmm thanks to you both, very handy information!

is there any documentation for the client script api ?

Hello @monojoker, were you able to do it finally? I am struggling with the same thing as well. Any help will be appreciated.

@ahmed In monojoker’s case, I think the problem was that he made the script under ‘Sales Order Item’ instead of ‘Sales Order’. Child table scripts need to be in the parent’s file.


Thank you. This drove me nuts :wink:

Hi Max_morais_dmm

How to fetch the value of city from address doc to customer customer doc i have created on custom filed that is city…

Have you tried to wrote in fetch from section of field city

1 Like

Use this of the field

1 Like