How to update a field value based on field from another document?

Hi,
I am having a custom field in Material request doctype. I want that field to get updated once the produced qty field in Work Order is updated. I tried the below custom script, but its not working, not sure which trigger to use and exact way to proceed on this.

frappe.ui.form.on(“Work Order”, {
produced_qty: function(frm) {
if (frm.doc.produced_qty == 1){
frappe.call({
“method”: “frappe.client.set_value”,
“args”: {
“doctype”: “Material Request”,
“filters”: {“name”:frm.doc.work_order_ref_no},
“fieldname”: “produced_qty”,
“value”: frm.doc.produced_qty
}
});
}

Kindly help, thanks!