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!
Best Answer
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.