Quickly provide Field & Object Permission

Quickly provide Field & Object Permission

Hi All,

Welcome to my new article.

We all know how much tedious process is to assign field permission and object permission to any profile or permission set.

We used to get bored doing/waiting while providing object and field permission to any particular profile or permission set.

Today we are going to see how we can provide the object and field permissions to any permission set without getting into User Interface.

We will see how easily we can provide permission of object or field using few tricks & functionalities.

Let's start with the process.

Use Case:

We have a permission set called 'Salesforce CPQ Add-On' which doesn't have object or field permission for the following objects.

  1. Product Action
  2. Product Attribute Set
  3. Product Feature
  4. Product Options
  5. Product Rules
  6. Products

For example, we have used only few objects.

No alt text provided for this image

In above screenshot, we can see that all the permission set doesn't have permission for the above mentioned objects.

Now follow the below mentioned steps to provide the object level permission to our permission set.

I have used Salesforce Inspector Chrome Plug-In for data query & insert, you can use any tool which supports querying data & support DML operation like Data Loader.

Provide Object Permissions

  • Open Salesforce Inspector by clicking 'Data Export'.

No alt text provided for this image

  • Add following query & click 'Export' button.

No alt text provided for this image

Note: Make Sure you have Use Tooling API checkbox checked.

  • Click 'Copy (Excel format)' button.
  • Open Microsoft Excel & Paste the copied content into it.
  • Prepare the object API name with NameSpacePrefix included. Use highlighted formula in excel to concat the values.

No alt text provided for this image

  • Now open another excel sheet & prepare the data set for providing Object Permissions.

To insert the permission for object, we have to make entries into object called 'ObjectPermissions' which has following fields.

  1. ParentId - It is the Id of Permission Set or Profile.
  2. SObjectType - It will contain the API name of the object.
  3. PermissionsCreate - It depicts whether the permission set or profile has Create access for the object.
  4. PermissionsRead - It depicts whether the permission set or profile has Read access for the object.
  5. PermissionsEdit - It depicts whether the permission set or profile has Edit access for the object.
  6. PermissionsDelete - It depicts whether the permission set or profile has Delete access for the object.
  7. PermissionsViewAllRecords - It depicts whether the permission set or profile has ViewAllRecord permission for the object.
  8. PermissionsModifyAllRecords - It depicts whether the permission set or profile has ModifyAllRecord permission for the object.

No alt text provided for this image

Note: To obtain the Id of permission set, please run following query with the API name of your permission set.

In my case, the API name of permission set is 'Salesforce_CPQ_Add_On'. Replace that with the API name of your permission set in below snippet.

Select id,Name from PermissionSet where name = 'Salesforce_CPQ_Add_On'        

  • We can get the API name of our Permission set by clicking Edit Properties button.

No alt text provided for this image

  • Select the data set we created and copy all the values including header.

No alt text provided for this image

Note: Since object 'SBQQ__ProductAttribute__c' has dependency on 'SBQQ__ConfigurationAttribute__c'. we have added Product2 object for now to avoid dependency error while insertion.

  • Go to Salesforce Inspector and click 'Data Import'.

No alt text provided for this image

  • As shown in below screenshot, please select necessary value.

No alt text provided for this image

  1. Action - Insert
  2. Object - ObjectPermissions
  3. Format - Excel
  4. Data - Paste the copied data from excel using CTRL + V.

As soon as you paste the data, records will be visible as a table on the bottom screen.

No alt text provided for this image

  • In field mapping, add '_' in the start of the first field if it contains any data or click link 'Skip'.
  • Click 'Import' button.
  • We will see a popup having 2 buttons 'Import' & 'Cancel'. Click 'Import' button over there.

No alt text provided for this image

  • We will see that it resulted into Status as 'Succeeded'.

No alt text provided for this image

  • Now let's have a look at the permission set and confirm the object permissions got added.

No alt text provided for this image

Provide Field Permissions

Consider that we wants to provide the field permission for following objects:

  1. Products
  2. Product Actions

  • First of all let's see whether field permissions are there or not?

No alt text provided for this image
No alt text provided for this image

  • Open Salesforce Inspector by clicking 'Data Export'.

No alt text provided for this image

  • Add following query & click 'Export' button.

No alt text provided for this image

Note: Make Sure you have Use Tooling API checkbox checked.

  • Click 'Copy (Excel format)' button.
  • Open Microsoft Excel & Paste the copied content into it.
  • Prepare the object API name with NameSpacePrefix included. Use highlighted formula in excel to concat the values.

No alt text provided for this image

  • Remove extra '__' which is available in the start of the text where NameSpacePrefix is blank.

No alt text provided for this image

  • Now open another excel sheet & prepare the data set for providing Field Permissions.

To insert the permission for object, we have to make entries into object called 'FieldPermissions' which has following fields.

  1. ParentId - It is the Id of Permission Set or Profile.
  2. SObjectType - It stores the Object API name.
  3. Field - It will contain the API name of the field.
  4. PermissionsRead - It depicts whether the permission set or profile has Read access for the object.
  5. PermissionsEdit - It depicts whether the permission set or profile has Edit access for the object.

No alt text provided for this image

Note: To obtain the Id of permission set, please run following query with the API name of your permission set.

In my case, the API name of permission set is 'Salesforce_CPQ_Add_On'. Replace that with the API name of your permission set in below snippet.

Select id,Name from PermissionSet where name = 'Salesforce_CPQ_Add_On'        

  • We can get the API name of our Permission set by clicking Edit Properties button.

No alt text provided for this image

  • Select the data set we created and copy all the values including header.
  • Go to Salesforce Inspector and click 'Data Import'.
  • As shown in below screenshot, please select necessary data.

No alt text provided for this image

  1. Action - Insert
  2. Object - FieldPermissions
  3. Format - Excel
  4. Data - Paste the copied data from excel using CTRL + V.

As soon as you paste the data, records will be visible as a table on the bottom screen.

  • Click 'Import' button.
  • We will see a popup having 2 buttons 'Import' & 'Cancel'. Click 'Import' button over there.

No alt text provided for this image

  • We will see that it resulted into Status as 'Succeeded'.

No alt text provided for this image

  • Now let's have a look at the permission set and confirm the field permissions got added.

No alt text provided for this image
No alt text provided for this image

I hope after going through this article it will be more easier for you to provide object permission or field permission to any permission set or profile.

Feel free to reach out if you have any questions on this.

Thanks,

Mehul Parmar

Jodie Miners

CISM, CPDSE | The Detail Department | Cybersecurity for Small Business | Business Technology Consultant | Salesforce MVP HoF | Salesforce Expert

3 年

Fabulous. They have done some great new features lately and more to come. I'd love to see any other posts you have about any other features of Salesforce Inspector. I use display fiekds, edit values, go to Setup, and export metadata only

回复
Jodie Miners

CISM, CPDSE | The Detail Department | Cybersecurity for Small Business | Business Technology Consultant | Salesforce MVP HoF | Salesforce Expert

3 年

Excellent use of Salesforce Inspector! Thanks! Salesforce Inspector is a free tool, but also check out Enabler4Excel that can also do Profiles (they say Permission Sets are coming) plus Create and Update fields and many other cool features. Both of these tools are indispensable in my daily Salesforce work https://www.xappex.com/docs/enabler4excel/admin-features/mass-managing-field-level-security-settings/

要查看或添加评论,请登录

Mehul Parmar的更多文章

社区洞察

其他会员也浏览了