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
Sam WardSam Ward 

If statement in a visualforce page to choose a different flow

Hi, 

I have the below code but I just keep getting a syntax error, I want to display 1 flow if the users country is united kingdom and if not it defaults to a different flow, Here is my code below: 

<apex:page standardController="Vacation_Request__c">

    <apex:sectionheader title="Holiday Request - {!$User.FirstName} {!$User.LastName}"></apex:sectionheader>

    {!IF(({!$User.Country} == 'United Kingdom'),
    

    <flow:interview name="Vacation_Request" finishLocation="{!URLFOR('/home/home.jsp')}">
        <apex:param name="var_UserId" value="{!$User.Id}"></apex:param>
        <apex:param name="var_Username" value="{!$User.FirstName} {!$User.LastName}"></apex:param>
    </flow:interview>,
    
     <flow:interview name="Canada_Vaction_Request" finishLocation="{!URLFOR('/home/home.jsp')}">
        <apex:param name="var_UserId" value="{!$User.Id}"></apex:param>
        <apex:param name="var_Username" value="{!$User.FirstName} {!$User.LastName}"></apex:param>
    </flow:interview>
     
     )}
     
</apex:page>


any help would be much appericated. 

Thanks 
Best Answer chosen by Sam Ward
Shaik Naga janiShaik Naga jani
Hi Sam,
some typo mistake, I corrected use below sample code
<apex:page standardController="Vacation_Request__c">

    <apex:sectionheader title="Holiday Request - {!$User.FirstName} {!$User.LastName}"></apex:sectionheader>

    <flow:interview name="Vacation_Request" finishLocation="{!URLFOR('/home/home.jsp')}" rendered="{!IF($User.Country == 'United Kingdom', true, false)}">
        <apex:param name="var_UserId" value="{!$User.Id}"></apex:param>
        <apex:param name="var_Username" value="{!$User.FirstName} {!$User.LastName}"></apex:param>
    </flow:interview>
    
     <flow:interview name="Canada_Vaction_Request" finishLocation="{!URLFOR('/home/home.jsp')}">
        <apex:param name="var_UserId" value="{!$User.Id}"></apex:param>
        <apex:param name="var_Username" value="{!$User.FirstName} {!$User.LastName}"></apex:param>
    </flow:interview>
     
</apex:page>
Thanks 
Shaik
 

All Answers

Shaik Naga janiShaik Naga jani
Hi Sam,

you need to use the 'rendered' attribute, it will be rendered the flow when the condition is the match.
Check below Code, it may help for you
<apex:page standardController="Vacation_Request__c">

    <apex:sectionheader title="Holiday Request - {!$User.FirstName} {!$User.LastName}"></apex:sectionheader>

    <flow:interview name="Vacation_Request" finishLocation="{!URLFOR('/home/home.jsp')}" rendered="{!IF(!$User.Country == 'United Kingdom', true, false)}">
        <apex:param name="var_UserId" value="{!$User.Id}"></apex:param>
        <apex:param name="var_Username" value="{!$User.FirstName} {!$User.LastName}"></apex:param>
    </flow:interview>,
    
     <flow:interview name="Canada_Vaction_Request" finishLocation="{!URLFOR('/home/home.jsp')}">
        <apex:param name="var_UserId" value="{!$User.Id}"></apex:param>
        <apex:param name="var_Username" value="{!$User.FirstName} {!$User.LastName}"></apex:param>
    </flow:interview>
     
</apex:page>

if it help for you please mark the best answer.

Thanks
Shaik
Sam WardSam Ward
Hi Shaik,

Thanks for the response, I've copied the code however I get the following error: 

Error: Incorrect parameter type for function 'not()'. Expected Boolean, received Text

Any ideas on this? 
Shaik Naga janiShaik Naga jani
Hi Sam,
some typo mistake, I corrected use below sample code
<apex:page standardController="Vacation_Request__c">

    <apex:sectionheader title="Holiday Request - {!$User.FirstName} {!$User.LastName}"></apex:sectionheader>

    <flow:interview name="Vacation_Request" finishLocation="{!URLFOR('/home/home.jsp')}" rendered="{!IF($User.Country == 'United Kingdom', true, false)}">
        <apex:param name="var_UserId" value="{!$User.Id}"></apex:param>
        <apex:param name="var_Username" value="{!$User.FirstName} {!$User.LastName}"></apex:param>
    </flow:interview>
    
     <flow:interview name="Canada_Vaction_Request" finishLocation="{!URLFOR('/home/home.jsp')}">
        <apex:param name="var_UserId" value="{!$User.Id}"></apex:param>
        <apex:param name="var_Username" value="{!$User.FirstName} {!$User.LastName}"></apex:param>
    </flow:interview>
     
</apex:page>
Thanks 
Shaik
 
This was selected as the best answer