In our last post, we discussed on bulk creation of custom fields but it had a lag. It did not successfully make the fields accessible to various profiles as it had all FLS or Field Level Security set as blank. Imbibing FLS settings for all fields individually can be painstaking if we have an incredible number of changes to be made. For a few, we can…
Click on the field>click on ‘Set Field Security’ > Check the checkboxes to make it read-only or visible.
But for the bulk number of fields, this does not help. Another workaround would be to just create a permission set and give the required access, it has its own shortcomings of adding to future complexities of the project.
So anything else really other than ticking boxes for so many fields and profiles?
Let’s try fetching the profiles along with fields that we want to give access to and check the XML for any related settings data.
Step 1 – Fetching related fields and profiles in VsCode
Step 2 – Investigating the fields and profiles in VsCode
You will receive various data under force-app\main\default under Objects and Profiles containing the necessary files having all the information in XML. Investigating the files we see, the access is not saved in the fields or Object itself but is indeed saved on the profiles XML.
Here we can see that under each profile, we have field permission tag for each field as highlighted above. I further made the editable and readable true for a profile for a field. Reading back the change in the org, the field became visible to that profile and the checkbox on the FLS in salesforce for that field was ticked !!
Step 3 – Final Blow
Open profile XML files in VsCode and do “find and replace All” of the editable and readable tags as shown.
As a precautionary step, do check that you do not do any change outside of the field permissions. We can see where all are the lines for change.