function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Custom Settings help



I am trying to utilize a custom setting and I after lurking through the doc I am absolutely clueless to how to update/insert/delete data from a custom setting.


My goal is at this point is to insert data into a custom setting like so:

ZoomSession__c session = ZoomSession__c.getInstance();
session.Name = '0101010101';
session.user_id__c = '0101010101';
session.id_token__c = '1111';
session.id_token_expire__c =;
session.session_token__c = '2222';
session.session_token_expire__c =;
session.modified_ts__c =;
insert session;
System.debug('\n\n\n\n' + ZoomSession__c.getAll() + '\n\n\n\n');


But I ge an exception:

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: SetupOwnerId (id value of incorrect type): [SetupOwnerId]


 But i do not have a field called SetupOwnerId...


I am totally lost, can anybody give me a hand with this please?







It seems you are using "Hierarchical Custom Settings". Since Hierarchical Custom Settings are used to hold different values for a field per Profile, User and Org-wide,it have a field called "SetupOwnerId", which holds the Id for which the record pertains to.


So, if you wanted to create a record pertaining to user Joe


User user = [Select Id from User where Name='Sanj"'];


ZoomSession__c session = new Test__c(SetupOwnerId=user.Id, session.Name = '0101010101'; session.id_token__c = '1111';......);
insert session;


Or Else you can use List Custom Setting


For more details visit below link ""


Mark it as resolved if it helps you.