Script to trigger change in another field

Hi there, i’m a beginner in ERPNext scripting and need some very simple help. How do I trigger the script to do something upon a change in a certain custom field. For example, when I change “Type of Customer” from Distribution Customers to Retail Customers, I want the script to update “Customer” field to “Retail”.

cur_frm.set_value("customer", "Retail Customer");

But I am not sure how to trigger this when I change the value in “Type of Customer”

use frappe.ui.form.on(“Doctype Name”, “field name”, function(frm) { [your code] });

1 Like