Tuesday, January 29, 2019

Restricting users from Editing a Field Based on Role

You can use SuiteScript to restrict users from editing a field based on the role. This can be done in User Event, Suitelet Form and Client side Script.

Function Type:

- User Event Script-Before Record Load

-Client Side-Page Init

-Suitelet Form-General Function (nlobjRequest.getMethod())

API Functions to use:

-nlapiGetRole()-returns an integer value of the current user role (for example: 1, 3, or 5). Note that the value of -31 is returned if a user cannot be properly identified by NetSuite. This occurs when the user has not authenticated to NetSuite, for example when using externally available (Available without Login) Suitelets or online forms.

 

-nlapiDisableField(fldnam, val)-returns void;

 

Examples/Samples

User Event Script and Client Side

 

if(nlapiGetRole() == desiredRole_InternalID){

nlapiDisableField(fldnam, val);

}

 

Suitelet

if(request.getMethod() == 'GET') {

var formObj = nlapiCreateForm('Form Title');

if(nlapiGetRole() == desiredRole_InternalID){

       var testField = formObj.addField('custpage_testfield', 'text', 'test');

       testField.setDisplayType('inline');

}

}

 

For more info

Execution Context: https://netsuite.custhelp.com/app/answers/detail/a_id/10253/kw/#N4252296-4

Field APIs: https://netsuite.custhelp.com/app/answers/detail/a_id/10254/kw/#N3058373475-1

nlobjField: https://netsuite.custhelp.com/app/answers/detail/a_id/10263#N917407985-10

No comments:

Post a Comment