0

I am trying to get the values from a custom setting for more than one instance of the setting. If I replace 'placeholder' with shay or austin it works.

list<string> names = new list<string>{'shay', 'austin'};

for(integer i=0; i < 2; i++){
     string placeholder1 = '\''+ names[i] +'\'';
     sendgridsettings__c sgs1 = sendgridsettings__c.getInstance(placeholder);

     string placeholder2 = names[i];
     endgridsettings__c sgs2 = sendgridsettings__c.getInstance('\''+placeholder+'\'')



*********************THIS WORKED BELOW******************
 tring placeholder1 = names[i];
 sendgridsettings__c sgs1 = sendgridsettings__c.getInstance(placeholder);
6

You can just get a value by name like this:

list<string> names = new list<string>{'shay', 'austin'};
for (string name : names) {
    sendgridsettings__c sgs = sendgridsettings__c.getInstance(name);
    // Use the setting instance
}

You don't need to add single quotes: they are only used when you define a string constant such as 'shay'.

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.