0

Based on the outcome I want to show different "titles" in the visualforce pageBlockSection.

This is what the result should look like:

"You have an overall of XXX Customers" or "You have in this area XXX Customers"

So far I have:

"{!if(myInput == '1000',warehouses.size  , warehouses.size)}"

I can't figure out how to combine my variables (warehouse.size) and plain text. (You have .... customers)

Thanks

1 Answer 1

1

You can use multiple merge statements in Visualforce:

{!...}{!...}{!...}

Or, you can use TEXT to convert a number to text:

{!TEXT(IF(...,...,...))}

Or, you can use apex:outputText:

<apex:facet name="header">
<apex:outputText value="You have {0} customers.">
  <apex:param value="{!if(...,...,...)}" />
</apex:outputText>
</apex:facet>
5
  • Hello @sfdcfox, thank you for your reply. However I am not sure how any of this can help me. What I am look for is a working version of this: {!if(myInput == '1000', 'You have an overall of' warehouses.size 'customers' , 'You have' warehouses.size 'customers in the area')}
    – Jan Tonnet
    Commented Apr 16, 2020 at 15:18
  • 1
    @JanTonnet <apex:outputText value="{!IF(myInput='1000','You have an overall of {0} customers','You have {0} customers in the area.')}><apex:param value="{!warehouses.size}" /></apex:outputText> should work (using the apex:facet in my answer), or the TEXT formula would work, too.
    – sfdcfox
    Commented Apr 16, 2020 at 15:23
  • Hello @sfdcfox thanks.This does work! What would it look like if I have more than 1 variable? Let's say: <apex:outputText value="{!IF(myInput='1000','You have an overall of {0} customers in the last {1} month','You have {0} customers in the area from the last {1} month.')}"><apex:param value="{!warehouses.size}" /></apex:outputText> Do I add another param value? What would the syntax be?
    – Jan Tonnet
    Commented Apr 16, 2020 at 15:40
  • 1
    @JanTonnet Yes, add more apex:param, one for each placeholder, up to 10 ( {0} through {9}).
    – sfdcfox
    Commented Apr 16, 2020 at 15:41
  • Thanks man! That was really helpful.
    – Jan Tonnet
    Commented Apr 16, 2020 at 15:45

You must log in to answer this question.

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