Assign Field Level Security(FLS) in Salesforce
In this blog we will see the easy way to update Field Level Security(FLS) for Permission sets/Profiles in bulk.
I have created a tool to make the Admins job a little easier. Before jumping to tool let us see the different standard approach we follow to update FLS in Salesforce.
As an admin we usually update FLS from salesforce setup/UI. If we are working on a new Application with many Permission sets and Objects with 100+ fields it can be very time consuming task. Using this tool we can assign FLS in just few mins.
Let us take an example. Suppose we have a new application and we have created 20 Permission sets and 8 Profiles. Now there are 10 Objects in all and in each object we have 15 fields for which we need to update FLS for above Permission sets and Profiles.
Let us first see the different approach to assign FLS in Salesforce. We have two ways in which we can update FLS for a particular field.
1.To update FLS for Profiles from Setup we can go to Object Manager choose Fields & Relationships and then we select the particular field to set Field-Level Security.
Setup -> Object Manager -> Fields & Relationships -> Select Field ->click set Field-Level Security
2. To Update FLS for Permission sets/Profile we go to Permission set/Profile from setup select the Permission set and from Object Settings we go to each Object and then update the FLS. This is time consuming with 20 Permission sets, 8 Profiles and 10 objects.
Copy the code and paste it in your org. Go to Home page or Record Page and add the 'FLS File Upload Tool' component in your page.
Source code :- Git Hub
Thank you all !
#Keep learning #Keep Sharing :)
Recent blogs:
How to use hyperlink in custom Toast Notification message in LWC
Nested Accordion in LWC
Build custom add to favorites functionality using LWC
Another approach that we can follow is by updating FLS via inserting data to FieldPermissions object.
To update the field permissions we need to prepare data with four columns that the 'FieldPermissions' object needs.
1. SobjectType - It stores the Object API name.
2. Field - It contains the Field API name.
3. PermissionsRead - It depicts whether the permission set or profile has Read access for the Field.
4. PermissionsEdit - It depicts whether the permission set or profile has Read/Write (Edit) access for the Field.
For example I have taken 3 Standard Object Account, Contact and Opportunity and 1 Custom Object Candidate with mix of custom and standard fields.
Here we will see step by step approach to prepare data and upload data using the Tool to update FLS.
Step 1: Get the list of Objects API name and Fields API name for which we need to give FLS.
Step 2: Concatenate the column SobjectType and Field with "."
Step 3: Delete the second column and add two columns with the Permission needed. (PermissionsRead and PermissionsEdit) .
Please check the headers it should be exactly same as in the below SS. These are the field API names of the FieldPermissions Object.
There can be chances that we are updating the Permission to Read Only from Edit so you can give FALSE in PermissionsEdit column and TRUE in PermissionsRead column.
Step 6: Select the all Permission sets and Profiles for which you need to provide FLS.
I have created some custom permission sets and custom profiles for example.
Step 8: Click Done.
Step 9 : Click Yes.
And finally we are done :)
Demo :
Copy the code and paste it in your org. Go to Home page or Record Page and add the 'FLS File Upload Tool' component in your page.
Source code :- Git Hub
Thank you all !
#Keep learning #Keep Sharing :)
Recent blogs:
How to use hyperlink in custom Toast Notification message in LWC
Nested Accordion in LWC
Build custom add to favorites functionality using LWC
Awesome 👍
ReplyDeleteThanks. Awesome.
ReplyDeleteAwesome. I have one small suggestion that you can give 2 more lookups. One for search objects and another for generating CSV. Suppose If I select the account then CSV should have all the fields and the fields you asking for update FLS.
ReplyDeleteGreat work !!!