Dynamically Change Label

Hi,

I am trying to change the label of a field in a custom form. Wrote this code in the Client Script. But it is not working. Is there any alternate solution?

function setDep(frm, cdt, cdn) 
{
    var cd = locals[cdt][cdn];
    if (frm.doc.deposit_type == 'Transfer')
       {
         frappe.web_form.set_df_property('deposit_type',   "label", "From Deposit Type");
       }
    else
       {
         frappe.web_form.set_df_property('deposit_type',   "label", "Deposit Type");
       }
}

Thanks,
Joseph

Hi @pjoseph,

If you talked about the custom doctype label change according to the dynamically so please apply the client script for that.

frappe.ui.form.on('Your DocType', {
    refresh: function(frm) {
        if (frm.doc.deposit_type == 'Transfer') {
            frm.set_df_property("deposit_type", 'label', "From Deposit Type");
        } else {
            frm.set_df_property("deposit_type", 'label', "Deposit Type");
        }
    }
});

Please set the doctype and field name in the script.

I hope this helps.

Thank You!

1 Like

Thanks a lot @NCP !!! Awesome !!!