function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Yashita Goyal 17Yashita Goyal 17 

Provide Object permission using data loader

In our product we have 250+ objects and 16+ profiles. I was given an assignment to prepare automation logic to provide profile level permissions to all these objects.

After all search on internert and salesforce guides was able to generate query which can be used to extract and update permissions using Apex data loader.

Below are my findings and if anyone looking for help:
  • To get all custom profile ID from target org. Extract them using below query:
Select Id,ProfileId,Profile.Name from PermissionSet where IsOwnedByProfile=true and isCustom=true
This query will extract all custom profile from the org.
To extract object permissions of all profiles:
SELECT Id, SObjectType, ParentId, Parent.ProfileId, Parent.Profile.Name, PermissionsCreate, PermissionsRead, PermissionsEdit, PermissionsDelete, PermissionsModifyAllRecords,PermissionsViewAllRecords FROM ObjectPermissions WHERE SobjectType = '<Specify Object API Name>' and parentid in (select Id from PermissionSet where PermissionSet.ProfileId IN ('<Specify Profile IDs>'))
You can much more, like Field permission, mass profile assignment to user.
Ref Links:

Thank you so much Yashita for Object permission article.
But I have exported based on parentid using below query. Could you please suggest me both queries are same or not. And each parentid has single profile or multiple profile?
SELECT ParentId,PermissionsCreate,PermissionsDelete,PermissionsEdit,PermissionsModifyAllRecords,PermissionsRead,PermissionsViewAllRecords,SobjectType FROM ObjectPermissions where parentid='target parentid' AND sobjecttype in  'APTS_Setting__c'