Explanation for client side script

Hey guys,
I know this must be self explanatory, but i am confused by this piece of code given in the wiki of wnframework.

    args: {
        doctype:"Delivery Note Item",
        filters: {
        fieldname:["qty", "stock_uom"]
    callback: function(r) { 

        // set the returned value in a field
        cur_frm.set_value(fieldname, r.message);

i want to get value of a field in item doc and want to set value to a field in batch doc. I feel this is the script i need to modify, But am confused with the args for the wn call method. Or just if anyone could explain the above code, i guess i will be able to make my case work.

Thanks a lot :smile:

HI Akarsh_Hegde,

args parameter simply forms sql query, like select qty, stock_uom from tabDelivery Note Item where parent =‘DN00038’ and item_code='Ser/003’

If you want to fetch a field on item selection, you also can use add_fetch() instead of wn.call()/frappe.call()


I thought add_field() is only used to fetch link fields from other doctypes. In add_fetch() i can only specify the doc type and the field. But i would like to fetch a field from a particular record. Say, i would like to take a field value of a particular item record. how can i do that ?

Considering, you want to fetch some field from item master to batch master.

cur_frm.cscript.add_fetch(‘items_link_field_name_from_batch’, ‘field_to_fetch_value_itemsform’, ‘field_to_set_value_batchform’)

Does this also work for other field types ? such as data or time ?

Yes, its works for date and time too.

Thank you. I hope this works.