function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ALimas22ALimas22 

Using variables in Custom Labels?

Hello,

 

I tried to use variables (merge fields) in  a custom label (used inside a VisualForce page) like this

 

<a href="something">View</a> case {!Case.CaseNumber} submitted on {!Case.CreatedDate}.

 

That doesn't work for and I'd like to find out if that custom label content/text needs to be formatted differently or if it's just not supported.

 

I tried to search around but didn't find any example/documentation about this.

 

Thank you.

 

al

patrospatros
I don't know about it working as a label, but does it work if you drop it elsewhere on the page?
ALimas22ALimas22

Thanks for the reply.

 

 > I don't know about it working as a label, but does it work if you drop it elsewhere on the page?

 

I'm not sure I understand the question.

 

When the VisualForce page makes a reference to the Custom Label, the variables are not substituted/expanded/merged, i.e. you'd see "View case {!Case.CaseNumber} submitted on {!Case.CreatedDate}".

 

If I inline (i.e. not through a Custom Label reference) the text shown above directly in the same VisualForce page, the variable substitution works as expected, e.g. you'd see "View case 00999999 submitted on Sun Oct 03 13:32:22 GMT 2008".

 

Another way of asking the same question I raised is if SFDC does the variable substitution before or after it inlines the Custom Labels in the generated HTML.  The behaviour seems to indicate that it does variable substitutions before inlining Custom Labels.

 

Whether that's the case or not, is there another way of using Custom Labels to avoid hard-coding parameterized text in VisualForce pages?  It's a pretty standard I18N mechanism available in many programming languages.  I've even used such mechanism just for simply externalizing configurable text/settings to be phrased/set differently for different implementations of your application.

 

Thank you.