0

I have a custom setting titled 'Authentication' and a field named 'token'.

I need to access the value stored in 'token' in Apex, but I'm not sure how to do so. I'm aware of the get Instance() method, but haven't been able to get it to work yet - what value do you pass to getInstance?

There will only ever be one value in the 'token' field.

Thanks in advance for any help

1
  • 1
    list custom setting or hierarchy custom setting? If List custom setting, you need to know the key of the record which will be the value of the name field
    – cropredy
    Dec 23, 2014 at 0:43

1 Answer 1

2

For a Hierarchy setting, use getOrgDefaults() to get the default value. If you use a List setting, then you need to pass in the name of the value you want to retrieve. Lists can store multiple rows of data, each one uniquely identified by its name. It doesn't matter what you name it, so long as the value is consistent.

1
  • Also if Hierarchy you can use getInstance(userInfo.getUserID()) if you store settings by user
    – Eric
    Dec 23, 2014 at 3:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.