function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rajesh k 10rajesh k 10 

how to give field level security visible permission using apexDML perticular profile?

Hi ,
       Actually i created fields using metadata api but created fileds Field-Level Security for Profile(Administrator) place visible and editable checkboxes not checked(any profile not checked i am a administrator).Every time i will goto Setup->Manage->users>administrator->custom field level security->related object name and click view and checked to metadata created fields visible and editable.How to check this visible and editable checkboxes Using apex DML permissionsets dynamically through Coding?.

please help me.........

Hi Rajesh , 

This is directly not possible - e you have to get the meta data through describe calls and then process , 

See the below links,



rajesh k 10rajesh k 10
Hi Ashish,
                          I am a new in salesforce.Please help me how to check field visible permission through coding i have administrator profile

Hi Mahesh, 

You have to retrive the metada for those Onjects which have these fields.

Once you have the Metadata you have to modify the Metadata to reflect the Visible permission.

Then Migrate themetadata using ANT.

Please see the links above which will  more information .

Set Field Level security for profile using meta-data api

Yes, it's possible, but it's not particularly easy. Unlike creating fields which you can utilize the "CRUD" based metadata api calls, profiles require using retrieve and deploy calls. This means you'll have to deal with zipping and unzipping the data for the deploy/retrieve calls, constructing the xml for the package manifest to do the retrieve call, and dealing with modifying the resulting xml. I'm not aware of any sample code for this unfortunately.

High Level Steps

1. List out Profiles

You'll need to list out all the profiles that you want to update the field level security for

2. Construct your Project Manifest

Build a package.xml that includes all profiles from step 1, and any fields you want to set the security for. Profiles only include permissions related to the other components in the next step, so you must retrieve them in conjunction with any components you're update the security for.

3. Do a retrieve call and unzip the result

Use your project manifest to do a retrieve call and unzip the resulting zip file.

4. Update the permissions

Update the profile XML with the desired permissions

5. Deploy the changes

Zip everything back up and do a deploy call.

Also See the links below,

Mitesh SuraMitesh Sura
Is there any attribute directly on customfield in metadata API that will make it available to all profiles in an org.?