1

I have looked at the documentation and it seems the best I can do is query ObjectPermissions for PermissionSet access.

Is it possible to do the same for Profile instead of PermissionSet?

THANKS FOR THE ANSWERS! I wrote an Apex script based off sfdcfox's links to documentation. Hope this helps anyone who stumbles on this question.

Map<Id, Id> permSetProfileMap = new Map<Id,Id>();
List<ObjectPermissions> profileObjectPermList = new List<ObjectPermissions>();


For(PermissionSet ps : [SELECT Id, ProfileId 
        FROM PermissionSet 
        WHERE IsOwnedbyProfile = TRUE]) {


permSetProfileMap.put(ps.id, ps.ProfileId);
}



For(ObjectPermissions op : [SELECT id, ParentId, PermissionsCreate, PermissionsRead, PermissionsEdit, PermissionsDelete, PermissionsViewAllRecords, PermissionsModifyAllRecords, SobjectType 
            FROM ObjectPermissions 
            WHERE ParentId
            IN: permSetProfileMap.keySet()]) {

profileObjectPermList.add(op);

}



For (ObjectPermissions op: profileObjectPermList) {
System.debug('Profile Id: ' + permSetProfileMap.get(op.parentId) + ' , sObject: ' + op.sObjectType + ' , Create: ' + op.PermissionsCreate + ' , Read: ' + op.PermissionsRead + ' , Edit: ' + op.PermissionsEdit + ' , Delete: ' + op.PermissionsDelete + ' , View All Records: ' + op.PermissionsViewAllRecords + ' , Modify All Records: ' + op.PermissionsModifyAllRecords);

}
  • Marginally helpful. – Adrian Larson May 19 '16 at 14:54
  • @AdrianLarson Sorry if I rubbed you the wrong way. I figured the question was detailed enough to be posted. – All about the W May 19 '16 at 15:27
  • You didn't rub me the wrong way. The link lays out what sfdcfox explained in more detail. I'm just not super familiar with it myself, so I didn't leave it as an answer. Did you not notice it's a link? – Adrian Larson May 19 '16 at 15:32
  • AHHH! I didnt realize it was a link! I figured I was getting flak for the one liner question. Thank you brofessor for the link! – All about the W May 19 '16 at 15:39
6

Profiles are replicated into a special type of PermissionSet. IsOwnedByProfile will be true, ProfileId will be set to the Profile's Id field. So, you can query PermissionSet to determine a profile's object, field, apex class, and Visualforce permissions via the associated security objects (e.g. ObjectPermissions). Also, see the User Access Visualization open source code from salesforce to see how they render a user's profile and permission set permissions.

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.