I have looked at this question but this is not working and I have the exact same requirement where I will have to pass the parameter to a custom label

string parameter = 'this is a test';
string label =  System.Label.test;
String value = String.format(label, parameter); 
System.debug('//' + value);

Here is the error:

Variable does not exist: String


You need a List to send 'parameter'

String value = String.format(label, new List<String>{ parameter });
|improve this answer|||||
  • ah ha got it... – Nick Kahn Sep 6 '16 at 20:24
  • Yeah, it looks like some SFDC error messages are not clear/helpful enough :P. A String.format(String, String) method doesn't exist would be more accurate I think. – Joca Sep 6 '16 at 20:50

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.