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/… – Kiran Mutturu Sep 30 '14 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. – Sanjay Kharwar Sep 30 '14 at 14:13
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. – Sanjay Kharwar Sep 30 '14 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 Oct 14 '14 at 12:48

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.