i have a client script that is referenced in a sui...
# ask-stanley-ai
n
i have a client script that is referenced in a suitelet and insufficient permission violation error appears even though there it is an administrator role thats accessing the suitelet form
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like the issue you're facing is related to the permissions of the user who is executing the client script, not the Suitelet. Even though the Suitelet is set to execute as an Administrator, the client script runs with the permissions of the current user. If you're trying to perform operations that require higher permissions (like search.lookup) within a client script, you might encounter a 'Permission Violation' error if the current user doesn't have the necessary permissions. To work around this, you can make the client script send a request to a Suitelet that performs the operation. The Suitelet can be set to execute with higher permissions. However, keep in mind that this essentially makes the information accessible to the Suitelet public. Here's a general idea of how you can structure this: Client Script:
Copy code
javascript
var suiteletURL = url.resolveScript({
    scriptId: 'customscript_suiteletid',
    deploymentId: 'customdeploy_suiteletid',
    returnExternalUrl: true
});

var response = https.get({ url: suiteletURL });
Suitelet:
Copy code
javascript
function onRequest(context) {
    if (context.request.method === 'GET') {
        var searchResult = search.lookupFields({
            type: search.Type.TRANSACTION,
            id: context.request.parameters.id,
            columns: ['field1', 'field2']
        });

        context.response.write(JSON.stringify(searchResult));
    }
}
Remember, this is just a general idea and you'll need to adjust it according to your specific needs. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.862812519
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.862279177
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.857055128
Please provide your feedback on this answer.