0

I'm currently using visualforce and apex to allow a user to manage their own Hierarchical Custom Settings. By design this allows non-admins the ability to edit their Hierarchical Custom Setting values as long as the setting's Location is their User.

However, this only allows the user to manage 1 instance of settings. I need to implement a concept whereby a non admin User can manage multiple instances of settings specific to them. In this way the User can define multiple settings specific to their needs (configurations) and regardless of how many instances (records) of __Mdt they define for themselves (their userID in a User__c field on the __mdt), I will require that the Owner/User__c using my app must self-select one of the __mdt records that they Own to be "active". In this way I'm implementing user-specific settings that support scenarios whereby the user defines multiple instances (records) of settings specific to them, and they can switch between them by "activating" one at a time (isactive__c)

Since Hierarchy Custom Settings are not perfect for me here, I'm exploring Custom Metadata. I need to know whether it is possible or not to allow non-system-admins the ability to manage (Create, Read, Edit, Delete) custom metadata (__mdt) records. This article suggests the answer is NO and requires "CustomizeApplication" but are there any workarounds to letting a regular User insert/delete __mdt via APEX? Maybe Andrew Fawcett knows. Perhaps its feasible to give them access to a visualforce page whereby its controller runs in system mode and is capable of deploying and undeploying __mdt metadata records?

Thanks everyone,

1
  • They're supposed to allow us to update custom metadata via Apex without the MDAPI, but I can't seem to find out when/how to do so. You might not want to give up quite yet.
    – sfdcfox
    Commented May 19, 2018 at 3:22

1 Answer 1

2

You cannot delete records from the Apex Metadata API at all, which means you'd have to use a library like apex-mdapi to talk directly to the underlying Metadata API to achieve full CRUD operations.

Connecting to the Metadata API requires the “API Enabled” and “Modify All Data” permissions, and you cannot system-mode end-run around that requirement.

1
  • Hey David, thanks for the source docs! Given this info, I will plan to use regular sobjects (private OWD ) to empower users to define a concept of user-specific "settings" in my app. As stated, hierarchical settings only support 1 entry per User which doesnt fit my needs (2 entries gives error : duplicate value found: SetupOwnerId duplicates value on record with id: <userid>). Custom metadata management would only work if everyone using my app were admins, which is not the case. Although sobjects cannot be packaged, they seem to be superior at solving this than hierarchy settings or __mdt Commented May 19, 2018 at 2:48

You must log in to answer this question.

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