You need to sign in to do that
Don't have an account?
Katharine Anderson 13
Check User ID against Permission Set Assignment in Trigger
So I have a trigger that I'm trying to write to update a value on a custom object when it is updated or created. The value should only be updated if the user does not have a certain permission set assigned to them. I have been trying to figure out how to check the user's ID against a list that contains the ids for the users that were assigned to that permision set, but I am fairly new to coding and googling is not working out. Maybe one of you can help? Here is my terrible code that isn't compiling:
trigger UpdatePermissions on box__FRUP__c (before insert, before update) { //Create list of Easement Managers based on the Permission Set: 'Easement Management Fields'. List<PermissionSetAssignment> EasementManagers = [Select AssigneeId FROM PermissionSetAssignment WHERE PermissionSetId = '0PS0c000000Pi9z']; //Check User ID against Assignee ID. If not in list, change FRUP permission to 'Read' instead of 'Read/Write'. { for (box__FRUP__c frup : Trigger.New) { if (frup.box__Salesforce_User__r.ID IN EasementManagers) //do nothing } else { frup.box__Permission__c = 'Read'; } } }
All Answers