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
James Moore 52James Moore 52 

Can you pass parameters to a Flow using URLFOR ?


I'm hoping it's possible to pass parameters to a flow using URLFOR and a custom button.  I've created a VF page to list instructors available on a specific lesson day by passing the parameters of the lesson record ID , and the Lesson date within the url of the VF page button.  Then created custom buttons to fire a Flow to "assign" or update the instructor on the lesson record.  My first attempt using <param name= 'name'> to pass the varInstructorId and the varLessonId was not working, so i'm trying to pass the parameters within the URLFOR command.

VF Page:
<apex:page standardcontroller="Schedule_Availability__c" recordSetVar="schedules" showHeader="FALSE" sidebar="False">
<apex:messages />
      <!-- CSS -->
    .lead {
      color: green; 
      font-weight: bold;    
    .assist {
      font-weight: bold; 
    <apex:form id="theForm">
        <apex:pageblock mode="maindetail"  title="{!$ObjectType.Schedule_Availability__c.label} for {!DATEVALUE($CurrentPage.parameters.Lesson__c.Lesson_Date__c)} "> 
            <apex:outputpanel id="Available">
                <apex:pageblocktable value="{!schedules}" var="s" columns="13" rendered="{!Schedule_Availability__c.Date__c= DATEVALUE($CurrentPage.parameters.Lesson__c.Lesson_Date__c)}" >
                    <apex:Column styleClass="header" headervalue="Instructor" value="{!s.Instructor_Volunteer__c}"/>
                     <apex:Column value="{!s.Discipline__c}"/>
                    <apex:Column styleClass="lead" Headervalue="Lead Skills" value="{!s.Lead_Instructor_Skills__c }" style="color:green"/>
                    <apex:Column styleClass="assist" Headervalue="Asst Skills" value="{!s.Assistant_Instructor_Skills__c}" style="color:red"/>
                    <apex:Column value="{!s.Date__c}"/>
                    <apex:Column value="{!s.Job_Roles__c}"/>
                    <apex:Column headervalue="AM" value="{!s.Booked_AM__c}"/>
                    <apex:Column headervalue="PM" value="{!s.Booked_PM__c}"/>                  
                    <apex:column headervalue="Eve" value="{!s.Booked_Evening__c}"/> 
                    <apex:column headervalue="Lead Instr.">   
                    <apex:commandButton action="{!URLFOR($Action.Lesson__c.Assign_Lead_Instructor,Id,[varInstructorId='s.Instructor_Volunteer__c', varLessonId='$'])}" id="assign" value="Assign Lead"/>           
                    <!--<apex:param name="varInstructorId" value="{!s.Instructor_Volunteer__c}"/>
                    <apex:param name="varLessonId" value="{!Id}"/>-->
                    <apex:column headervalue="Asst 1">   
                    <apex:commandButton action="{!URLFOR($Action.Lesson__c.Assign_Asst_1, Id)}" id="asst1" value="Assign Asst 1"/>
                    <apex:param name="varInstructorId" value="{!s.Instructor_Volunteer__c}"   />        
                    <apex:param name="varLessonId" value="{!Id}"/>
                    <apex:column headervalue="Asst 2">   
                    <apex:commandButton action="{!URLFOR($Action.Lesson__c.Assign_Asst_1, Id)}" id="asst2" value="Assign Asst 2"/>           
                    <apex:param name="varInstructorId" value="{!s.Instructor_Volunteer__c}"   />  
                    <apex:param name="varLessonId" value="{!Id}"/>
                    <apex:column headervalue="Asst 3">   
                    <apex:commandButton action="{!URLFOR($Action.Lesson__c.Assign_Asst_1, Id)}" id="asst3" value="Assign Asst 3"/>           
                    <apex:param name="varInstructorId" value="{!s.Instructor_Volunteer__c}"   />  
                    <apex:param name="varLessonId" value="{!Id}"/>
        <apex:panelGrid columns="3">
          <apex:commandButton action="{!previous}" value="Previous"/>
          <apex:commandButton action="{!next}" value="Next" />
          <apex:commandButton action="{!cancel}" value="Close Window" />


Custom Button:

There are a few other issues i'm having with this page, but the most critical is inserting the Instructor__c onto the Lesson Record.  I'm trying  to stay away from apex, since this will need to be maintained by a non-profit without developer resources.  
James LoghryJames Loghry

URLFOR is an odd duck in that it doesn't support dynamic parameters or merge fields as parameters.  Instead, the alternative would be something like 
{!URLFOR($Action.Lesson__c.Assign_Lead_Instructor,Id)} + "?varInstructorId={!s.Instructor_Volunteer__c}&varLessonId={!$}"

Alternatively, you could figure out the Flow URL in Apex and return a PageReference with the appropriate parameters.
James Moore 52James Moore 52

Thanks James (great name!) So here's what i tested: 
<apex:column headervalue="Lead Instr."> <apex:commandButton action="{!URLFOR($Action.Lesson__c.Assign_Lead_Instructor,Id)} +?varInstructorId={!s.Instructor_Volunteer__c}&varLessonId={!$}" id="assign" value="Assign Lead" > </apex:commandButton> </apex:column>
However the flow is still not picking up the varInstructorId. Will this not be possible using this method?