0

I need to figure out if values in PermissionSet for current user are changed in trigger, i'm thinking about using oldMap but i can't figure it out.

Maybe this code will explain what i'm trying to do:

    for (User u : trigger.New)
    {
        List<PermissionSetAssignment> lstOldPermSet = Trigger.oldMap.get(u.id).PermissionSetAssignments;
        List<PermissionSetAssignment> lstNewPermSet = // get PermissionSetAssignments via soql query

        if(lstOldPermSet != lstNewPermSet)
        {

// code goes in here

        }

    }

Any suggestions?

  • I am not sure but do you want to compare all the values and all the permissionSet attached to a user ? – Merabti Ibrahim Jul 26 '17 at 8:44
  • Try posting entire code – Saumya Gaikwad Jul 26 '17 at 9:21
  • PermissionsSetAssignment do not allow trigger manipulation. Are you using iTriggers? – Saumya Gaikwad Jul 26 '17 at 9:32
  • @MerabtiIbrahim I need to run certain code when user get's or loses PermissionSetAssignment. – Nikola Naumovski Jul 26 '17 at 14:01
  • @SaumyaGaikwad What are iTriggers? Can you explain a bit more? – Nikola Naumovski Jul 26 '17 at 14:02
1

The after update trigger on User object will fire only when you will update any field of the User object.

If you will add or remove thePermissionSets, the trigger on User object will not fire.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.