function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Javascript Button Help

I have the following jscript button. It checks the users permission set and work accordingly but it requies user to have "View Setup and Configuration" permission at the user level. We have users without that permission and not able to submit the records. Can someone please assist how to make this button work without assigning "View Setup and Configuration" permission to users? I am getting the following error.
User-added image
try {
    var result = 
            "SELECT Id " +
            "FROM PermissionSetAssignment " +
            "WHERE PermissionSetId = '0PSK00000004T11' " +
            "AND AssigneeId = '{!$User.Id}'"

    var psAssignment = result.getArray("records");
    if (
        "{!Pims__c.Status__c}" !== "Under Review" &&
        psAssignment.length === 1
    ) {
        var isContinue = confirm("Are you sure you want to submit ? Click OK to continue or Cancel to remain on the screen.");

        if (isContinue) {
            var PimstoUpdate = new sforce.SObject("Pims__c");

            PimstoUpdate.Id = "{!Pims__c.Id}";
            PimstoUpdate.Status__c = "Under Review";

            var result = sforce.connection.update([PimstoUpdate]);

            if (result[0].success === "true") {
            } else {
                    "An Error has Occurred. Error: \r\n" +
    } else {
} catch (e) {
        "An unexpected Error has Occurred. Error: \r\n" +

Swayam  AroraSwayam Arora
Try calling apex method from the button. Apex class should not have With Sharing keyword. Code will run in System mode.

Please close the thread marking this answer as Best Answer if it really helped. Closing the thread help others finding the correct answer.