Is there a way to get the list of roles that are available in an Netsuite account? I am working on a provisioning solution with Netsuite and I am very new to netsuite. if an
To view Roles list:
Go to Setup > Users/Roles > Manage Roles
There is a work around to get the list :
Create a saved search on the employee record with role in the search column (group) and then use search API to get this search result.
There is a REST role service that can retrieve all accounts, roles and domains available for a user:
URL: https://rest.netsuite.com/rest/roles
Headers:
GET /rest/roles HTTP/1.1
Accept: */*
Accept-Language: en-us
Authorization: NLAuth nlauth_email=johnsmith@xxxxx.com, nlauth_signature=****
For more details, see the help documentation (Netsuite login required).
This is example :
$nsroleObject = new RecordRef();
$nsroleObject->internalId = $roleId ? $roleId : $this->_accountInfo['nsrole'];
$passPort = new Passport();
$passPort->email = $this->_accountInfo['nsemail'];
$passPort->password = $this->_accountInfo['nspassword'];
$passPort->account = $this->_accountInfo['nsaccount'];
$passPort->role = $nsroleObject;
$loginRequest = new LoginRequest();
$loginRequest->passport = $passPort ;
$result = $this->netsuiteService->login($loginRequest);
if ( !$result || !$result->sessionResponse->status->isSuccess ) {
return false;
}
// if success, update roles list
$this->_wsRoleList = $result->sessionResponse->wsRoleList->wsRole;
A successful Login request to Suitetalk (Netsuite Webservices) returns list of all roles available. http://tellsaqib.github.io/NSPHP-Doc/class_net_suite_service.html#ae54779a9faa0c0be881b5ed284c5e8b3