Salesforce Fact #522 | Hierarchical custom settings insertion error

Have you come across this error: SetupOwnerId duplicates value on record id with id: <some record id>.

This error is encountered when we are trying to insert a record in hierarchical custom settings and there is already a record present in the same level of hierarchy. For example, the below example tries to insert a org level row in the custom settings Location__c:

insert new Location__c(name='test hcs');

and there is already the org level row present in the org.

Comments

Popular posts from this blog

Salesforce Fact #192 | Call batch apex from flow

Salesforce Fact #457 | Get current user role name in flow