Salesforce | Change Visibility of several fields of an object

|
| By Webner

Problem: Change Visibility of several fields of an object.

Need: One example is when a package is deployed to another org then the visibility of the fields can be different than expected which affects the functionality.

Solution: Since editing each field one by one in each object will be time-consuming so we can use manage profile. Steps to change visibility :

1. Go to Setup.

2. Select Profiles in Manage Users or Search Profile :

1

3. Select Profile System Administrator so that all the functionality keeps working :

2

4. After selecting profile go to section “Field-Level Security” :

3

5. Here in this section, there are two Sub-Sections :

a. Standard Field-Level Security (For Standard objects).
b. Custom Field-Level Security (For Custom Objects).

6. Select an object (Click on view).

7. There you can see all the fields of that object with field type and access :

4

8. Now you can change the access to the fields by clicking the edit button.

Note: If you have too many columns and you have to change their access all at once that is either all accessible or hidden then you can execute jquery in the console of a browser.

Code Snippet :Run this code to add jQuery since this jQuery Library is not added in Salesforce :

var jQueryScript = document.createElement('script');
jQueryScript.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jQueryScript);
jQuery.noConflict();

Now you have to execute following code to check all the fields in the table column :

jQuery('.readonlyCol input[type=checkbox]').prop("checked", true);

.readonlyCol is Parent class (read access td) – verify this at your end. To uncheck all the fields in the column change prop(“checked”, true) to prop(“checked”, false)

5

Leave a Reply

Your email address will not be published. Required fields are marked *