Sunday, March 17, 2019

Disable/Hide a Field Depending on Logged In User's Role

For this example, Company Name field of Client (Customer) records will be disabled for the following roles: Administrator, Accountant, Bookkeeper.

1. Create a javascript file with the code below:
 function beforeLoad() {
       nlapiGetField('companyname').setDisplayType('disabled');
 }


Note: To get a list of the standard field IDs to use in the nlapiGetField call, please refer to the SuiteScript Records Browser - https://system.netsuite.com/help/helpcenter/en_US/RecordsBrowser/2013_1/index.html

2. Create a new User Event script by navigating to Customization > Scripting > Scripts > New > User Event. Use the javascript file from step 1 as the script file. Set beforeLoad as the Before Load Function of the script. For more information on creating scripts, please see Answer ID 10553.

 

3. In the script deployment, select only the preferred roles where field needs to be disabled & defined in the script.

No comments:

Post a Comment