Home

Monday, 2 January 2023

sfdc-learn #7 : Parameterized Custom Label

We can use parameters in custom label by using String.format(string, List<Parameters>) function.

This function contains first parameter as string label and second parameter is List of parameter.

Example:

 Custom Label name: Parameterized_Custom_Label

  Label value: Hi,{0} welcome to {1}-{2}.

    

List<String> parameters = new List<String>();

parameters.add('Test');

parameters.add('sfdc');

parameters.add('learn');

String strLabel = Label.Parameterized_Custom_Label;

String value = String.format(strLabel, parameters);

System.debug('value::'+value);


Output:

16:57:19:008 USER_DEBUG [7]|DEBUG|value::Hi, Test welcome to sfdc-learn.

No comments:

Post a Comment