Unrestricted Search Permissions in Client Scripts

When running a search on client scripts, the permission level is always set to the user's currently logged in role. This may cause problems if the role does not have view permissions to the record. This restriction can be bypassed with the following workaround.

Unrestrict search permissions on client scripts

  1. Update the client script to send a GET HTTP request to a Suitelet that will run the search you want to run. Values can be passed using the URL parameters. For example:

       url: stSuiteletUrl + '&orderId=' + stOrder 
       var objResponse = JSON.parse(response.body);
    }).catch(function onRejected(reason) {
  2. Create the Suitelet that will run the search. Make sure it is configured to run as Administrator.

    • URL parameters can be accessed using the context.request.parameters argument. For example:

                          let stOrderId = scriptContext.request.parameters.orderId; 
    • Search results can be returned using the context.response.write() method. For example:

         output: JSON.stringify({
            status: 'success',
            results: arrResults

The unrestricted results will be passed to the client script.

Related Topics

Using the currentRecord Module in Client Scripts
Client Script Role Restrictions
Interfacing with Remote Objects in Client Scripts
SuiteScript 2.x Client Script Reference

General Notices