Unrestricted Search Permissions in Client Scripts

When you run a search in a client script, it uses your current role's permissions. This can cause issues if your role doesn't have permission to view the record. Here's a way to get around this limitation:

Unrestrict search permissions on client scripts

  1. Update your client script to send a GET HTTP request to a Suitelet that runs your search. You can pass values using URL parameters. For example:

                    https.get.promise({
       url: stSuiteletUrl + '&orderId=' + stOrder 
    }).then(function(response){
       var objResponse = JSON.parse(response.body);
    }).catch(function onRejected(reason) {
       console.log(reason);
    }); 
    
                  
  2. Create the Suitelet that will run the search. Make sure it's set to run as an Administrator.

    • You can access URL parameters using the context.request.parameters argument. For example:

                          let stOrderId = scriptContext.request.parameters.orderId; 
      
                        
    • Return your search results using the context.response.write() method. For example:

                          scriptContext.response.write({
         output: JSON.stringify({
            status: 'success',
            results: arrResults
         });
      }); 
      
                        

The unrestricted results will be passed to the client script.

Related Topics

General Notices