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
Hitendra SabhadiyaHitendra Sabhadiya 

How to set Field level security using metadata api from C# or Java Application ?

mukesh guptamukesh gupta
Hi Hitendra,

Please follow below url:-

https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_quickstart_java_sample.htm

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
SandhyaSandhya (Salesforce Developers) 
Hi,


I believe you will need to use the Profile (https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm) metadata to set field level security. Profile has a fieldLevelSecurities field, which is a collection of ProfileFieldLevelSecurity (https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm#profilefieldlevelsecurity_title).

There is an example of setting these values using the Metadata API in C# in Set Field Level security for profile using meta-data api (http://salesforce.stackexchange.com/a/58243/102)
 
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
 
Hitendra SabhadiyaHitendra Sabhadiya
Hi


When I  create Custom object from C# Application using metadat api ,so it will be created in my developer org.
but I have to manually check field level scurity for fields of object for my profile.
I have System Administrator Profile.

So pls Give me Example.
I have  already tried your solution but it doesn't work.
 
Maunish Shah 22Maunish Shah 22
Hi All,

Was anyone able to resolve this challenge?
I am working on a C# tool that creates custom fields in SFDC and as of now, as there is no FLS assigned, the field is not available for the user to add in the layouts. Because, the field should have FLS defined for that user's role/profile.