0


I Like to use custom label same way as I can use in Apex class. I like to use it in java script alerts/messages.
My main concern is "How to pass some argument so that I can use it within java script code of VF"
i.e. string.format(System.Label.msg, new string[] {‘Label’}) <br />

Where Label.msg = 'Hello, I am a {0}

But I am not able to use it.

2
  • check this may be worth reading salesforce.stackexchange.com/questions/32746/… Commented Sep 30, 2014 at 12:16
  • This does not fulfill my use case...... My use case … I have a form with 4 text box and I want to make blank validation using java script. I have created a method and I like to show alert message according to blank field. For that I like to create just single custom label, “{0} can not be blank” and in my code I pass field name as an argument and in Apex page there should be proper message. Commented Sep 30, 2014 at 14:13

1 Answer 1

0

Use this

{!$Label.YOUR_CUSTOM_LABEL_NAME}

Reference: https://www.salesforce.com/us/developer/docs/pages/Content/pages_variables_global_label.htm

2
  • Thanks Vignex, I am looking for “how to pass some argument to custom label ?” i.e. something like this {!$Label. CUSTOM_LABEL_NAME, ‘SOME_ARGUMENT’} and output should be same as it used in Apex class. Means output should be according to passed argument. For use case … Let I have a form with 4 text box and I want to make blank validation using java script. I have created a method and I like to show alert message according to blank field. For that I like to create just single custom label, “{0} can not be blank” and in my code I pass field name as an argument. Commented Sep 30, 2014 at 14:05
  • @SanjayKharwar Custom label is just a text (with multi language support). It is not a function. You have to manually parse the text and replace with your value.
    – Vignex
    Commented Oct 14, 2014 at 12:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .