You need to sign in to do that
Don't have an account?

Query from list custom settings
Hi
I am trying to query my endpoint from custom setting in my RESTFULL call.
I created a object and a customfield in custom setting and made it public.
I gave my endpoint in that customfield(asdefaultvalue).
In my apex class Icreated a list and trying to query that field from that object.
But Iam getting nullvalue. Please help if I am missing something.
String endpoint=Customsetting__c.getInstance('label of field').API name of field__c ;
All Answers
u should do some thing like this;
MyCustomSettingsobject__c obj = MyCustomSettingsobject__c .getInstance('name of the custom settings');
String url = obj.field__c;
system.debug('-----------------------------url---->'+url);
Please refer below code for retriving List Custom Setting Value
When you add data in list custom setting there is one record created for it. Pass that record name to getValues('RecordName') function. you get instance og it.
myCustomSetting__c myCustomSetting = myCustomSetting__c.getValues('RecordName');
String dataValue = (myCustomSetting.customField__c != null) ? myCustomSetting.customField__c : '';
I hope this works for you.
What should be the name of custom settings?My API name of custom setting or field API name??
Both the ways my log is showing null in this line..
MyCustomSettingsobject__c obj = MyCustomSettingsobject__c .getInstance('name of the custom settings');
Any help where i am going wrong?Thank you in advance
Same issue with your code.I am getting mycustomsetting value in log as null.Guess i am missing something.could you please correct me.?
setup-->develop--> custom settings --> click manage on ur custom setting --> u see the name of ur custom setting
just copy paste.
String endpoint=Customsetting__c.getInstance('label of field').API name of field__c ;