You need to sign in to do that
Don't have an account?

Dynamic Custom Label
Is there a possibility to use dynamic custom labels in apex. I know you can do this with VF, but i can't find it for apex.
Custom label = 'You have used {0} in {1} Hours'
in apex
String text = Label.used(List<String>('12','2');
in spring12 this feature is there.....
All Answers
Hi,
You can try the below code sample
<apex:page controller="clsActionSupport">
<apex:form >
<apex:pageBlock >
<apex:outputPanel id="Text">
<apex:outputText value="{!count}"> </apex:outputText>
<apex:actionPoller reRender="Text" interval="5" action="{!increment}"/>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
public class clsActionSupport
{
integer count =0;
public pagereference increment()
{
count = count + 1;
return null;
}
public integer getcount()
{
return count;
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
No this is not what i mean.
Custom label is used for translations of text in visualforce and apex. It is an salesforce object.
but u can try like this
I know that solution as well. I need it in a purely apex method. For if you wish to add custom text to an email or use it in a trigger.
in spring12 this feature is there.....
Okay thanks!
Are not you looking for the following syntax? This has been there for a long time.
String errorMessage = System.Label.LabelName ;
for(Account obj: accountList){
if(Obj.Name != 'TestAccount'){
dataTableSetting.addError(String.format(errorMessage, new List<String>{obj.Name}));
}
}