You need to sign in to do that
Don't have an account?
amoldavsky
Custom Settings help
Hey,
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 = Datetime.now(); session.session_token__c = '2222'; session.session_token_expire__c = Datetime.now(); session.modified_ts__c = Datetime.now(); 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?
Thanks
-Assaf
Hi,
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 "http://cloudnow.wordpress.com/2011/04/20/custom-settings-how-and-why/"
Mark it as resolved if it helps you.
Cheers
Sanj