+ Start a Discussion

use standard error message from app in visual force page, passing parameter to labels

Hi, I have a couple of questions around labels.


1)Is there any way I can leverage a standard error message from app (Error: Invalid Data. Review all error messages below to correct your data.) in my visual force page?   I checked $Label.site merge field, but don't see this error listed there.

2) If the answer to the above question is no, I guess my next option would be to use "error" label (Error: {0}) from $Label.site merge field. But can someone tell me how I can pass the {0} parameter to this label.


I am aware that I can create my own custom label to do this. But I am trying to leverage the standard functionality as much as I can for obvious reasons and hence these questions.







It all depends how much flexibility you want in your error messages. If you're rely on validation rules you're quite restricted. You can build your own ApexPages.Messages(http://www.salesforce.com/us/developer/docs/pages/Content/apex_pages_message.htm) and add these to your page when an exception is thrown and then you have maximum flexibility. I wouldn't recommend mixing the two though.


If you'd like to use parameters in error messages using custom labels this too is possible. An article about this can be found here .







Only way I know is to use a param and the outputText:




                <apex:outputText value="{!$Label.link_create_conf}">
                    <apex:param value="{!chosenPropertyContact.Property__r.Street__c}"/>
                    <apex:param value="{!chosenPropertyContact.Property__r.City__c}"/>
                    <apex:param value="{!chosenPropertyContact.Property__r.Postcode__c}"/>
                    <apex:param value="{!selectedTob.Name}"/>
                    <apex:param value="{!selectedTob.Short_Description__c}"/>
                    <apex:param value="{!selectedTob.Client__r.Name}"/>