Change 1 dropdown value based on input of another

Hi,

I have created 2 custom fields(type = select) in the Appraisal template doc type.
namely : rating(Good, Bad, Excellent, Satisfactory,unsatisfactory) , Score(1,2,3,4,5)

these fields are created in a child table named goals, now i am have written a client script to execute on this child table but somehow it never works. Here is the code:

frappe.ui.form.on(“Appraisal Template Goal”, {
refresh(frm) {
{
if (cur_frm.doc.rating == “Excellent”)
{ cur_frm.set_df_property(“score”, “options”, [“1”,]);
} else if (cur_frm.doc.rating == “Good”)
{ cur_frm.set_df_property(“score”, “options”, [“2”,]);
} cur_frm.refresh_field(“score”);
}
}
});

ERPNext version : 14

I am new to this script writing & ERPNext customization but have reached here following a previous thread:

Any help in this regard will be appreciated.

Best Regards.

Hi @garry999,

Please apply it.

frappe.ui.form.on("Appraisal Template Goal", {
    rating: function(frm, cdt, cdn) {
        var d = locals[cdt][cdn];
        if (d.rating == "Excellent") {
            frappe.model.set_value(cdt, cdn, 'score', '1');
        }
        else if (d.rating == "Good") {
            frappe.model.set_value(cdt, cdn, 'score', '2');
        }
    }
});

Then reload and check it.

Thank You!

works like a charm @NCP
Many thanks.