Categories
Salesforce

DUPLICATE_VALUE, SetupOwnerId custom setting

A type of custom setting that uses a built-in hierarchical logic that lets you “personalize” settings for specific profiles or users. The hierarchy logic checks the organization, profile, and user settings for the current user and returns the most specific, or “lowest,” value. In the hierarchy, settings for an organization are overridden by profile settings, which, in turn, are overridden by user settings.

Hierarchy settings have a SetupOwnerId, which defaults here to the Organization level since you do not populate it. There must be only one setting instance per SetupOwnerId, which is why you get the error.

Hierarchy settings are the wrong tool for what you are doing. Based on what you seem to be implementing, you want either a List Custom Setting (not recommended for new implementations), a Custom Object, or a Custom Metadata Type. I think a Custom Object is the most likely choice.

Leave a Reply