1

In Apex code running in a trigger I need to check permission for MetadataType doing something similar to this:

Schema.getGlobalDescribe().get('objectName').getDescribe().fields.getMap().get('fieldName');

and then I get the field describe from the SObjectField to use the isAccecible() method but answer is false for most of the profiles. I can't give Customize Application permission to this profiles so the question is: Is there a way to give Metadata Type field access to a profile.

Only thing I could find is go to Setup -> Profile -> select profile -> Custom Metadata Type -> add the Metadata type in Enabled Custom Metadata Types list but I'm not able to access the fields. I was expecting this will make the field also accesible but is not is only the object the one that the user is getting access not the fields. So the question is, Is there a way to give field permission to a Metadata Type or it is just that it is assumed to run in System context so nobody bothered to create field permissions for the Metadata Type fields.

Thanks!

1 Answer 1

1

No.

There is no way to provide field level security (FLS) on metadata types.

The idea behind the metadata types is it's a system level function that can be used to drive the behaviour of your app. It's not a regular object that users interact with on a daily basis.

3
  • Please make sure it is enabled at --> Quick Find | Schema Settings | Restrict access to custom metadata types. And I suppose triggers run in system mode, so custom metadata type should be accessible. Functionality that runs in system mode is not affected by access permissions, so even if they do not have access, code would work. Feb 9, 2022 at 6:11
  • Nick, I agree on the purpose, but then following doesn't make sense. Why do you allow access to a Metadata type through Profile, and then you don't give access to the Metadata type fields. I would expect ok Profile gives user access to this Metadata Type then also allow fields specially if there is no way to set field level security as you are mentioning.
    – ymiki
    Feb 9, 2022 at 19:05
  • Praveen, thank you so much. Your post is giving me some light. I will play with it.
    – ymiki
    Feb 9, 2022 at 19:07

You must log in to answer this question.

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