I have around 200 profile and i have to give them Read,Create,Edit,Delete,ViewAll and Modify All rights on a particular Object say "Employee".

I don't want to edit all 200 profiles one by one and give them rights on that particular object.

Is there any centralized place or code through which i can give these rights without editing each profile separately?

4 Answers 4


There are two ways of granting access to an object to every single profile in organization.

The first way is useful for Salesforce Administrators since this way doesn't need to write any code.

This is the way suggested by Guy here and Himanshu Parashar in this topic.

  1. Check if you have Enhanced Profile List View Feature enabled. For this, go to Setup\Customize\User Interface under Setup header enter image description here

  2. Then go to Profile List View and Create a new View and add CRUD permissions for the object you need. You need to input the object name into search edit box and select all six CRUD setting for given object and click add button to include them in selected settings and then click save to save the view. enter image description here

  3. Then you need to check 'Select All' checkbox on the topmost-left corner of the view, then check "Modify All" and "Create". For each setting you need to select "All selected records' radio option and hit save. enter image description here

And then access should be granted to all profiles. Note then for some profiles checkbox may still be unchecked, these are standard profiles and we can't modify those options.

Another way is for Salesforce Developers.

You can just open Developer Console and Execute such code there:

public static void grantAccess( String sObjectName ) {
    // Strange but when I try to delete old records it raises internal salesforce error, but it works anyway even if we don't delete the previous records
    //Database.delete( [ select id from ObjectPermissions where Parent.IsOwnedByProfile = true and SobjectType = :sObjectName  ], false );
    List<ObjectPermissions > os = new List<ObjectPermissions >();
    List<PermissionSet> ps = [ select id from PermissionSet where IsOwnedByProfile = true];
    for (PermissionSet p:ps) {
        os.add( new ObjectPermissions(
            ParentId = p.Id, 
            SobjectType = sObjectName,
            PermissionsCreate = true,
            PermissionsDelete = true,
            PermissionsEdit = true,
            PermissionsModifyAllRecords = true,
            PermissionsRead = true,
            PermissionsViewAllRecords = true
    Database.insert(os, false);


Since we can't detect if Salesforce profile is custom or standard, we need to put second parameter as false to allow partial success in the code.

  • On step 3, the checkmarks and unchecked boxes don't seem to be editable for me. Am I missing something? Commented Jan 4, 2018 at 16:34
  • 1. Do you use Salesforce Classic? Do you see the same view? 2. Do you have System Administrator profile?
    – Patlatus
    Commented Jan 4, 2018 at 16:45
  • I use Lightning, but I just realized that to edit I have to double click on the permission. Commented Jan 4, 2018 at 16:47
  • (I discovered this by accident because I was frustrated that clicking the little pencil icon did nothing and so I clicked it a bunch of times in exasperation). Commented Jan 4, 2018 at 16:48

Why not use list views to do this?

  1. create a list view on Profiles, filtering on the profiles you want to modify
  2. add only the columns Read,Create,Edit,Delete,ViewAll and Modify All for the objects you want to assign (by searching on 'object permissions'
  3. save the list view
  4. tick the 'select all' checkbox at the top-left of the list view
  5. check the 'modify all' checkbox on one of the records. The system will ask you if you want to apply the change on all selected profiles.

Yuck. First, can you merge some profiles through the use of permissions sets?

Either way, there's a free app called The Permissioner which makes stuff like that easier.

Do you want to write code every time you add a field that needs to go to all 200 of them?

  • No i don't want Commented Jul 22, 2013 at 6:15

For your query we neeed to fetch first the object permissions then modify it and again commit it to the server.

So for fetching the object permission you need to query like this

Map(id,Profile) profid = Map(id,Profile)(select id from profile); I am using () brackets as it is not accepting the text in <> brackets This return the list of profileIds and profile

Now query for the object permissions

SELECT Id,ParentId,PermissionsCreate,PermissionsDelete,PermissionsEdit,PermissionsModifyAllRecords,PermissionsRead, PermissionsViewAllRecords,SobjectType FROM ObjectPermissions where parentId in :profId.keyset() and SobjectType = 'XXXXX' XXX--> Custom Object Type

This will return u the complete list of permissions on the current object for all the profiles.

Now iterate throught this list and update the permission and agarin update the list back to the salesforce.

  • [SELECT Id,ParentId,PermissionsCreate,PermissionsDelete,PermissionsEdit,PermissionsModifyAllRecords,PermissionsRead, PermissionsViewAllRecords,SobjectType FROM ObjectPermissions where parentId in :profId.keyset()] It is returning 0 results. i think we are checking it against a wrong column Commented Jul 17, 2013 at 14:21
  • 1
    That's because it won't work with Profile IDs, ObjectPermissions only works with Permission Sets: "Represents the enabled object permissions for the parent PermissionSet. To grant a user access to an object, associate an ObjectPermissions record with a PermissionSet that’s assigned to a user. ObjectPermissions records are only supported in PermissionSet, not in Profile. This object is available in API version 24.0 and later."
    – Daniel N
    Commented Jul 17, 2013 at 18:11

You must log in to answer this question.

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