Client Script Role Restrictions

Client scripts respect the role permissions specified in the user's NetSuite account. An error is thrown when running a client script to access a record with a role that does not have permission to view or edit the record.

The following client script attaches to a custom sales order form and executes when the fieldChanged entry point is triggered:

          /**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 */
define(['N/search'],
    function(search) {
        function getSalesRepEmail(context) {
            var salesRep = context.currentRecord.getValue({
                fieldId: 'salesrep'
            });
            var salesRepEmail = search.lookupFields({
                type: 'employee',
                id: salesRep,
                columns: ['email']
            });
            alert(JSON.stringify(salesRepEmail));
        }
  
    return {
        fieldChanged: getSalesRepEmail
    }
}); 

        

If you are logged in with an administrator role, you receive the alert when you load the sales order with this form. If you are logged in with a role that does not have permission to view/edit Employee records, you receive an error when you select the Sales Rep field.

The following considerations can help prevent users from receiving the error:

Related Topics

General Notices