I have client-side logic that is triggered by an A...
# suitescript
e
I have client-side logic that is triggered by an Approve button created from a beforeLoad on the user event script. I created a group that contains the designated approvers which is basically a list of employees who can approve a vendor bill. When one of the designated approvers clicks on the button, a client-side error is generated and NS complains that the user doesn't have permissions to make changes to the group - YOU_ARE_NOT_ALLOWED_TO_MODIFY_THIS_GROUP. However, there isn't anything in the code that is setting any value. I am just loading that group record and generating an array of the members to compare with who triggered the Approve button to check if they are a designated approver. This is from a record.load operation so it looks like NS is assuming that a record.load presupposes edit/update permissions and the group setting is limited to edits by the group owner. Using search just adds unnecessary overhead to a simple "who are the members of this group" query.
c
Yeah NS equates record.load to the edit permission, so a search lookup is unfortunately your best bet.
😞 2
d
Or a query. In general that will be faster than a load anyway. I just did this in our product.
👍 1
Copy code
if(/entitygroup/i.test(type)
        && runtime.getCurrentUser().getPermission({name:'LIST_CRMGROUP'})
    ) {
      // LIST_CRMGROUP - does the user have permission to view/list the entity groups
      let grps = getEntityGroups();
      log.audit('GROUPS',grps);
      return grps;
    }
Copy code
let sql = `SELECT 
              ID AS id,
              groupname as fullname,
              concat(concat(grouptypename,' '),concat(groupmembership,' Group')) as title,
              email,
              'entitygroup' as type,
              grouptypename as grouptype
            FROM 
              EntityGroup
            WHERE 
               AND NVL(isprivate, 'F') = 'F' 
               AND NVL(isinactive, 'F') = 'F' 
               AND restrictiongroup IS NULL
            `