Tuesday, April 23, 2019

Determine if NetSuite account is a OneWorld or Non-OneWorld account

Determine if NetSuite account is a OneWorld or Non-OneWorld account

A unique identifier of a OneWorld Account is Subsidiaries. There are instances wherein users would like to know if the account is a OneWorld or not. Below, are two ways of how to achieve this through script:

Note: nlapiGetSubsidiary or nlobjContext.GetSubsidiary will return the current user's subsidiary for OneWorld accounts and '1' for non-OneWorld accounts. A better way to differentiate the accounts is to use a unique identifier for OneWorld accounts.

Server Side Script:

var isOneWorld;
var companyInfo = nlapiLoadConfiguration('userpreferences'); //gets user preferences
var acctSubsidiary = companyInfo.getFieldValue('subsidiary'); //gets subsidiary from user preferences
if(acctSubsidiary!=null){ //if subsidiary is not null
   isOneWorld = true; //account is a OneWorld account
}else{
   isOneWorld = false; //account is NOT a OneWorld account
}

Client Side Script:

var isOneWorld;
try{
   var temp = nlapiCreateRecord('subsidiary'); //attempts to create a subsidiary record
   //if no error occurs, script proceeds
   isOneWorld = true; //account is a OneWorld account
}catch(e){ //catches the error
   isOneWorld = false; //account is NOT a OneWorld account
}

 

No comments:

Post a Comment