1

Going through Setup > new Permission Set... it seems it would take a long time to update all Objects to Read Access, and make sure Edit Access = false.

Is there a faster way in Workbench or DevConsole?

If only I could query all Objects on a Permission Set... then I could run it in Dev Console and edit Object.ReadAccess = true in line.

So far, here's my best attempt with the query

SELECT PermissionSetId, AssigneeId, PermissionSet.Name
FROM PermissionSetAssignment
WHERE PermissionSet.Name = 'ABC'

1 Answer 1

2

You can write a quick Execute Anonymous script. Note that this obviously needs to run as administrator.

String permissionSetName = 'Test'; // Change me
Set<String> objectNames = Schema.getGlobalDescribe().keySet().clone();
PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = :permissionSetName];

ObjectPermissions[] permissions = [SELECT sObjectType, PermissionsRead, PermissionsEdit FROM ObjectPermissions WHERE ParentId = :ps.Id];

for(ObjectPermissions permission: permissions) {
    permission.PermissionsRead = true;
    permission.PermissionsEdit = false;
    permission.PermissionsModifyAllRecords = false;
    objectNames.remove(permission.sObjectType);
}

for(String theType: objectNames) {
    permissions.add(
        new ObjectPermissions(
            ParentId = ps.Id,
            sObjectType = theType,
            PermissionsCreate = true,
            PermissionsRead = true
        )
    );
}

permissions.sort();

Database.upsert(permissions, false);

The allOrNone parameter is used to avoid describe calls you'd need to make to figure out which objects to update. This should work even in very large orgs with thousands of objects, but you should limit this to one or two permission sets at a time.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .