Can someone tell me why the below is not populatin...
# suitescript
p
Can someone tell me why the below is not populating the Department field in an Opportunity? The subsidiary is populating. The console.log is showing the correct department id.
Copy code
if (context.mode == 'create') {
            var user = runtime.getCurrentUser();
            var subsidiary = user.subsidiary;
            nlapiSetFieldValue('subsidiary', subsidiary);
            var departmentId = user.department;
            console.log('Department Id is ' + departmentId);
            nlapiSetFieldValue('department',departmentId);
        }
k
You might want to try afterFieldSourcing as NS would use field sourcing to populate the field first and will overwrite your change.
p
thanks. tried that but still no good.
k
Is this is client side? If it is then maybe switch to do it in UE.
p
it is. was running this on pageInit.
k
Ah your mixing ss1 with ss2
p
I am but afaik that should not matter. I thought you were able to do this
k
Possibly but not something I would do 😂 I would move to beforeSubmit and do it there. There should be no issue then.
b
k
Yep that is an option
Never used it myself
b
is mandatory when sourcing is involved