Skip to content

Instantly share code, notes, and snippets.

@jsullivanlive
Created December 11, 2019 09:05
Show Gist options
  • Save jsullivanlive/289ddd9f2a7f12985f5e48689682c239 to your computer and use it in GitHub Desktop.
Save jsullivanlive/289ddd9f2a7f12985f5e48689682c239 to your computer and use it in GitHub Desktop.
ram copy permission sets when switching profile
/*
Set<Id> permissionSetIds = new Set<Id>();
for (PermissionSetAssignment psa : [
select PermissionSetId
from PermissionSetAssignment
where AssigneeId = '005d0000001rkdpAAA'
]) permissionSetIds.add(psa.PermissionSetId);
System.debug(JSON.serialize(permissionSetIds));
*/
Set<Id> permissionSetIds = (Set<Id>)JSON.deserialize('["0PS0W000001CPd1WAG","0PS0W000001GeWiWAK","0PS0W000001XQjiWAG","0PS0W000001oDArWAM","0PSd0000000GuTPGA0","0PSd0000000GuzkGAC","0PSd0000000GvJaGAK","0PSd0000000GycVGAS","0PSd0000000GyzAGAS","0PSd0000000H0BNGA0","0PSd0000000H2HYGA0","0PSd0000000H2WEGA0","0PSd0000000H2vJGAS","0PSd0000000H3RFGA0","0PSd0000000vZUjGAM","0PSd0000000vZUyGAM","0PSd0000000vaEwGAI","0PSd0000000vbIaGAI","0PSd0000000vcPDGAY","0PSd0000001GZWwGAO","0PSd0000001GZbwGAG","0PSd0000001T8iwGAC","0PSd0000001bXHSGA2"]', Set<Id>.class);
List<PermissionSetAssignment> newAssignments = new List<PermissionSetAssignment>();
for (Id permissionSetId : permissionSetIds) {
newAssignments.add(new PermissionSetAssignment(
PermissionSetId = permissionSetId,
AssigneeId = '005d0000001rkdpAAA'
));
}
Database.insert(newAssignments, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment