I have a client script, which runs on purchase ord...
# ask-stanley-ai
m
I have a client script, which runs on purchase order lines it runs fine and it's checking if the respective line item has a specific property set on the item record however, when the user uses the Employee Center role, I get this message: INSUFFICIENT_PERMISSION Permission Violation: You need the 'Lists -> Items' permission to access this page. How can I adjust the script to work, without adding more permissions?
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that the issue you're facing is due to the fact that the Employee Center role doesn't have the necessary permissions to access the 'Lists -> Items' page. This is because client scripts execute as the current user, and thus are subject to the permissions of the role that the user is currently using. One way to work around this issue is to have your client script call a Suitelet that can run as admin to perform the necessary checks. This way, the Suitelet will have the necessary permissions to access the 'Lists -> Items' page, and the client script can then retrieve the results from the Suitelet. Here's a basic example of how you can set this up: Client Script:
Copy code
javascript
var url = url.resolveScript({
    scriptId: 'customscript_my_suitelet',
    deploymentId: 'customdeploy_my_suitelet',
    returnExternalUrl: true
});

var response = https.get({ url: url });

// Parse the response and perform necessary checks
Suitelet:
Copy code
javascript
function onRequest(context) {
    var itemId = context.request.parameters.itemId;

    // Perform necessary checks on the item

    context.response.write(JSON.stringify(result));
}
Remember to set the Suitelet to 'Available Without Login' and to run as an admin role in the deployment settings. This way, the Suitelet will be able to access the 'Lists -> Items' page regardless of the role of the user who is executing the client script. ****** 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.850284159
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.848162532
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.847339869
Please provide your feedback on this answer.