Salesforce/Development

Custom Label Parameter

어디다쏨 2019. 12. 2. 23:48
728x90

Custom Label에서 파라미터를 사용하여 변수를 지정하여 사용 할 수 있습니다.

Label name: MyTestLabel
Label value: Thank you, {0}, for your feedback.

List<String> parameters = new List<String>();
parameters.add('John');

String label = Label.MyTestLabel;
String value = String.format(label, parameters);
You can do it in one line like this as well:

String.format(Label.MyTestLabel, new String[]{'John'});
String.format(Label.MyTestLabel, new List<String>{'John'});

참고 : 
https://salesforce.stackexchange.com/questions/40042/parameterized-custom-label
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm#apex_methods_system_string

728x90