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
louisa barrett 7louisa barrett 7 

Visual force pages with shared controller and visual flow

I need to get a collection variable from a flow and then pass it to another vf page.
The problem is the constructor is being called again and causing the flow variable to be null. I have set the redirect to be false, but this doesn't seem to be making any difference.
If I remove the flow aspect from the page, it works fine.
I've copied in the extension class and the two visual force pages.
Does anyone know if this is possible when calling a flow from the first page?

Extention class:
public class DeliveryNoteFlowController 
{
    private final Opportunity myOpp;
    
    public DeliveryNoteFlowController(ApexPages.StandardController stdController) {
        this.myOpp = (Opportunity)stdController.getRecord();
        system.debug('Opp ID = ' + myOpp.Id);
    }
    
    public Flow.Interview.DeliveryNote myflow { get; set; }
      
    public List<OpportunityLineItem> getMyOLIs() 
    {
        if (myflow == null) 
        { 
            system.debug('Flow is null');
            return null; 
        }
        else 
        {
            system.debug('OLI count = ' + myFlow.SelectedOLIs.Size());
            return (List<OpportunityLineItem>)myflow.SelectedOLIs;       
        }
    }
    
    public PageReference getFinishLocation()
    {
        PageReference pgr = Page.DeliveryNote3;      
        pgr.setRedirect(true);
        return pgr;
    }  
}
VF page that launches flow:
<apex:page standardController="Opportunity" extensions="DeliveryNoteFlowController">    
    <flow:interview name="DeliveryNote" interview="{!myFlow}" finishLocation="{!FinishLocation}">
        <apex:param name="OppId" value="{!Opportunity.id}"/>
    </flow:interview>
</apex:page>

 VF page(DeliveryNote3) that is called for the finish location. This page renders as a pdf:
<apex:page standardController="Opportunity" extensions="DeliveryNoteFlowController" standardStylesheets="false" applyHtmlTag="false" sidebar="false" readOnly="true" showHeader="false" renderAs="pdf">
    <head>
        <style type="text/CSS">
            body{
            font-family:"Verdana",Helvetica,Arial,sans-serif;         
            }
            
            .table-bordered {
            border: 1px solid #A9A9A9;
            border-collapse : collapse;
            font-size : .7em;
            border-width: thin;
            }
            
            .table-noborder {
            border: 0;
            font-size : .7em;
            }
            
            thead>tr>th {
            vertical-align: bottom;
            border: 1px solid #202d79;
            border-spacing: 0;
            text-align:left;
            border-collapse: collapse;
            background : #202d79;
            color:white;
            }
            
            .td-noborder {
            vertical-align: bottom;
            border:0 ;
            border-spacing: 0;
            border-collapse: collapse;
            text-align:left;
            width:50%;
            }
            
            td {
            vertical-align: center;
            border: 1px solid #A9A9A9;
            border-spacing: 0;
            border-collapse: collapse;
            text-align:left;
            }
            
            .header>td{
            font-weight:bold;
            background : #c4c4c4;               
            }
            
            .echoArea>td{
            padding:10px;
            }
        </style>
    </head>
    <body>
        <img src="{!$Resource.Logo}" alt="Our Logo" align="right" width="250" height="50"/>
        <header>
            <h2>Delivery note for <br/> {!Opportunity.Account.Name}</h2>
            {!myOppName}
            {!myOpp}
        </header>
        <p>Details</p>
        <table width="100%" class="table-noborder">               
                <tr>
                    <td class="td-noborder">Delivery Note No: {!Opportunity.Opportunity_External_ID__c}</td>                
                    <td class="td-noborder" width="15%" align="left">
                           Install Date: <apex:outputField value="{!Opportunity.Install_Date__c}"/>
                    </td>
                </tr>
                <tr>
                <td class="td-noborder">Project Manager: {!Opportunity.Project_Manager__c}</td>
                <td class="td-noborder" width="15%" align="left"></td>
                </tr>
                <tr>
                    <td class="td-noborder">Address:<br/>{!Opportunity.Account.BillingStreet}<br/>{!Opportunity.Account.BillingCity}<br/>{!Opportunity.Account.BillingState}<br/>{!Opportunity.Account.BillingPostalCode}</td> 
                    <td class="td-noborder"></td>
                </tr>                          
        </table>       
        <p>Products</p>
        <table width="100%" class="table-bordered">
            <thead>               
                <tr>
                    <th>Product</th><th>Quantity</th>
                </tr>
                <apex:repeat var="oli" value="{!MyOLIs}" >
                     <tr>
                        <td align="left">{!oli.Name}</td>
                        <td align="left">{!FLOOR(oli.Quantity)}</td>
                    </tr>                  
                </apex:repeat>
            </thead>
        </table>
        <br/>
        <table width="100%" class="table-noborder">
            <tr>
                <td class="td-noborder">Placeholder text

                </td>
            </tr>
        </table>
		 <br/>
        <p>Received by</p>
        <p>
            <i>Signature__________________________________________________</i><br/> 
            <br/>
            <i>Print name_________________________________________________</i>
        </p>
        <p>
            Date______________________________________________________        
        </p> 
          
    </body>
</apex:page>

Many thanks for any assistance