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.
- Product Action
- Product Attribute Set
- Product Feature
- Product Options
- Product Rules
- Products
For example, we have used only few objects.
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'.
- Add following query & click 'Export' button.
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.
- 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.
- ParentId - It is the Id of Permission Set or Profile.
- SObjectType - It will contain the API name of the object.
- PermissionsCreate - It depicts whether the permission set or profile has Create access for the object.
- PermissionsRead - It depicts whether the permission set or profile has Read access for the object.
- PermissionsEdit - It depicts whether the permission set or profile has Edit access for the object.
- PermissionsDelete - It depicts whether the permission set or profile has Delete access for the object.
- PermissionsViewAllRecords - It depicts whether the permission set or profile has ViewAllRecord permission for the object.
- PermissionsModifyAllRecords - It depicts whether the permission set or profile has ModifyAllRecord permission for the object.
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.
- Select the data set we created and copy all the values including header.
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'.
- As shown in below screenshot, please select necessary value.
- Action - Insert
- Object - ObjectPermissions
- Format - Excel
- 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.
- 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.
- We will see that it resulted into Status as 'Succeeded'.
- Now let's have a look at the permission set and confirm the object permissions got added.
Provide Field Permissions
Consider that we wants to provide the field permission for following objects:
- Products
- Product Actions
- First of all let's see whether field permissions are there or not?
- Open Salesforce Inspector by clicking 'Data Export'.
- Add following query & click 'Export' button.
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.
- Remove extra '__' which is available in the start of the text where NameSpacePrefix is blank.
- 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.
- ParentId - It is the Id of Permission Set or Profile.
- SObjectType - It stores the Object API name.
- Field - It will contain the API name of the field.
- PermissionsRead - It depicts whether the permission set or profile has Read access for the object.
- PermissionsEdit - It depicts whether the permission set or profile has Edit access for the object.
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.
- 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.
- Action - Insert
- Object - FieldPermissions
- Format - Excel
- 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.
- We will see that it resulted into Status as 'Succeeded'.
- Now let's have a look at the permission set and confirm the field permissions got added.
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.
Kindly also subscribe to my youtube channel SFDC Learning to get learning from video tutorials.
Feel free to reach out if you have any questions on this.
Thanks,
Mehul Parmar
Comments
Post a Comment