Client Script Role Restrictions

Client scripts follow the permissions set up in your NetSuite account. You'll get an error if you try to run a client script to access a record without the right permissions.

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're logged in as an administrator, you'll get 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.

To avoid this error, consider the following:

Related Topics

General Notices