I have created few custom fields via metadata api, but the field security by default is invisible. My request is to help provide apex code to update the field level security for all profiles at the same time.Please help me create an apex code not any link to some metadata api document or xml code. I have already done a lot of r&d but no success. Please dont provide solutions to do it via admin, i can do that, all i want is an apex code or any reference to solve the above problem


1 Answer 1


Profiles cannot be directly updated via APEX. Its one of the security restriction.

Well There is a workaround for that. APEX MDPI(https://github.com/financialforcedev/apex-mdapi) which helps you to change metadata in APEX.

These below links will help. Updating profile via Metadata API from Apex gives weird error

An alternate solution will be. Download all the profile metadata, Write a Java code to update the visibility and deploy it back.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .