the logged-in user is a member of groups name contains "Nxt". allow to assign INC

varma2
Mega Sage

Hi All.

the logged-in user is a member of any group name contains "Nxt". If they are, then allow them to assign tickets to the following groups
AP-NTT-PS-Support , SAP-T-APO-Support , SAP-N-MII-Support
How can we achieve this trough ACL.

Please provide the some script to achieve this requirement.
 
Rgards
 
 
14 REPLIES 14

J Siva
Tera Sage

Hi @varma2 
Instead of using ACLs, try implementing this with a Before Business Rule using the abort method.
Trigger the business rule when the assignment group changes to any of these groups AP-NTT-PS-Support , SAP-T-APO-Support , SAP-N-MII-Support

  var userID = gs.getUserID();
  var gr = new GlideRecord('sys_user_grmember');
  gr.addQuery('user', userID);
  gr.addQuery('group.name', 'CONTAINS', 'nxt');
  gr.query();

  if (gr.hasNext()) {
    gs.info('User is part of a group with "nxt" in the name.');
  } else {
    gs.info('User is NOT part of any group with "nxt" in the name.');
//Use abort method here
  }

Regards,
Siva

HI @J Siva 

I have used below script in acl but its not working.

 

 (function() {
    // Define the allowed assignment groups
    var allowedGroups = [
        "SAP-T-PS-Support",
        "SAP T-APO-Support",
        "SAP-T-MII-Support"
    ];

    // Check if the current user is part of any group with "Nxt" in the name
    var isUserInNxtGroup = false;
    var grMember = new GlideRecord("sys_user_grmember");
    grMember.addQuery("user", gs.getUserID());
    grMember.query();
    while (grMember.next()) {
        var group = grMember.getElement("group").getRefRecord();
        if (group && group.name.toLowerCase().includes("nxt")) {
            isUserInNxtGroup = true;
            break;
        }
    }

    // Deny if not part of a "Nxt" group
    if (!isUserInNxtGroup) {
        return false;
    }

    // If user is in a Nxt group, ensure they are setting an allowed assignment group
    if (current.assignment_group) {
        var assignedGroupName = current.assignment_group.getDisplayValue();
        return allowedGroups.indexOf(assignedGroupName) !== -1;
    }

    return false;
})();
 
Thank you
 

@varma2 I don't think you can acheive this using ACL.

 Hi @J Siva ,
How can we achieve this?


Thank you

 

@varma2 As i mentioned try using the before business rule instead of ACL.
Whenever the assigned group changes to any of those three groups, trigger the business rule.
Then chcek if the loggedin user is part of the nxt group. Based on the validation either abort or allow the operation.