How to check/select all fields checkboxes at Field Level Security of Object in Profiles

Many times, we come across such a situation when we are in a hurry or deployment on head or more than 100 fields to be checked for field-level security. This happens mostly at the time of deployment or UAT is going on. In large organizations, objects have more than 100 fields, and checking and unchecking all of them become a nightmare for a Developer/Admin/tester/QA. It gives pain to hands as well, because we click hundreds of times.

Why not have such scripts, which make this job easy and handy.

I am writing down the JavaScript code snippet, which will help us to do this job.

Js for marking all field check/uncheck at Field Level Security of an object at Profile Level. 
The below code is Not applicable for Enhanced Profile User Interface.



To mark all check-box true for Visible column

1
2
3
4
5
var arrayVisible = document.getElementsByClassName('displayedCol');
for(i=0;i<arrayVisible.length;i++){
if(arrayVisible[i]['firstElementChild']!= undefined)
arrayVisible[i]['firstElementChild'].checked = true;
}





To mark all check-box fields for ReadyOnly column


1
2
3
4
5
var arrayReadOnly = document.getElementsByClassName('readonlyCol');
for(i=0;i<arrayReadOnly.length;i++){
if(arrayReadOnly[i]['firstElementChild']!= undefined)
arrayReadOnly[i]['firstElementChild'].checked = true;
}



The below code is Applicable for Enhanced Profile User Interface.



Use whenever you want to save your precious time.


Comments

Popular posts from this blog

How to change/update the profile of a User in Salesforce from apex code

Deep Dive into Salesforce to Salesforce Connection

File Migration from One Salesforce Org to Another Org using Skyvia