Custom script with if conditions

Dear all,

Thanks for your help in advance. I read all the other topic regarding custom script with if conditions but could not make it work for my case.

Problem: in a document (purchase order) I fetch two distinct fields(A & B), from two different sources (A comes from Customer and B comes from shipping address) . But I would like field A to be overwritten with filed B only if B is not empty.

This is what I wrote without success:

frappe.ui.form.on(“purchase order”, {
onload: function(frm) {
if(frm.doc.B!==“”) {
frm.set_value(“A”, “B”);
}
}});

Any help or suggestion is highly appreciated.
Best regards,

Michele

Can someone please give me any tip on how to solve this.
Thanks in advance for helping a poor guy with no coding experience :blush: