+ 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.........
Ashish_SFDCAshish_SFDC

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, 

http://stackoverflow.com/questions/11438593/salesforce-field-level-security-for-user-object

http://salesforce.stackexchange.com/questions/30240/how-do-modify-all-data-and-view-all-data-affect-field-level-security-setting

https://developer.salesforce.com/page/Enforcing_CRUD_and_FLS

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_perms_enforcing.htm


Regards,

Ashish

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

thanks,
mahesh
Ashish_SFDCAshish_SFDC
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.

http://salesforce.stackexchange.com/questions/34521/set-field-level-security-for-profile-using-meta-data-api


Also See the links below, 

http://salesforce.stackexchange.com/questions/8783/full-list-of-all-accessible-types-through-metadata-api

http://salesforce.stackexchange.com/questions/21722/are-profile-and-permission-set-metadata-files-getting-all-project-objectpermissi


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