Populating Order Item Attribute based on user

Hi,

I am trying to write a custom code to default warehouse on each item based on user (In future would like to change it to a more complex quantity logic). Using the below code:

frappe.ui.form.on("Sales Order Item", {
    refresh: function(frm) {
        // use the __islocal value of doc, to check if the doc is saved or not
if(user=="xxxx@gmail.com" && frm.doc.__islocal){
        frm.doc.warehouse = "ABC";}
if(user=="xxxx1@gmail.com" && frm.doc.__islocal){
frm.doc.warehouse = "DEF";}   
    }
});

I am very new to coding and am using online help to get through.
This one doesnt seem to work.

Any suggestions around this would really be helpful.

Thanks
Nitin

@NitinAgarwal

try

frm.set_value("warehouse", "DEF"); 

Thanks for your help @rmehta

I think I may doing something wrong because even with the new snippet it doesn’t seem to work. I have tried placing the same in both order item custom script and order custom script.

frappe.ui.form.on(“Sales Order Item”, {
refresh: function(frm) {
// use the __islocal value of doc, to check if the doc is saved or not
if(user=="xxx@gmail.com"){
frm.set_value(“warehouse”, “DEF”);}
}
});

I am trying to achieve an automatic defaulting of Warehouses based on users.
Also, Is there any documentation that could help me understand and write client side scripts better.

Regards,
Nitin