Determine if Users’s Netsuite Account is a OneWorld/Non-OneWord Account by SuiteScript

Scenario 

User would like to determine if NetSuite account is One-World by using SuiteScript

Solution

A unique identifier of a OneWorld Account is the use of Subsidiaries which are not available otherwise.

Below are two other methods to determine whether an account is OneWorld or not via scripting:

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
}

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.

Leave a comment

Your email address will not be published. Required fields are marked *