# Get Flow Variable Values to a Visualforce Page

Flow variable values can be displayed in a Visualforce page. Once you’ve embedded your flow in a Visualforce page, you can use Visualforce markup to get values for variables or record variables. To display values for a collection variable or a record collection variable, you can use Visualforce markup to get the individual values contained in the collection.

:::note
You can get only variables that allow output access. If you reference a variable that doesn’t allow output access, attempts to get the variable are ignored. Compilation can fail for the Visualforce page, its `<apex:page>` component, or the Apex class.
:::

The following example uses an Apex class to get a record variable value from a flow and then displays it in a Visualforce page.

```apex_code
public class FlowController {
    public Flow.Interview.flowname myflow { get; set; }
    public Case apexCaseVar;
    public Case getApexCaseVar() {
        return myflow.caseVar;
    }
}
```

```visualforce
<apex:page controller="FlowController" tabStyle="Case">
    <flow:interview name="flowname" interview="{!myflow}"/>
    <apex:outputText value="Default Case Priority: {!apexCaseVar.Priority}"/>
</apex:page>
```

This example uses an Apex class to get the values that are stored in a string collection variable (`emailsCollVar`) in the flow. Then it uses a Visualforce page to run the flow interview. The Visualforce page iterates over the flow’s collection variable and displays the values for each item in the collection.

```apex_code
public class FlowController {
    public Flow.Interview.flowname myflow { get; set; }

    public List<String> getVarValue() {
        if (myflow == null) { 
            return null; 
        }
        else {
            return (List<String>)myflow.emailsCollVar;
        }
    }
}
```

```visualforce
<apex:page controller="FlowController">
    <flow:interview name="flowname" interview="{!myflow}" />
        <apex:repeat value="{!varValue}" var="item">
        <apex:outputText value="{!item}"/><br/>
        </apex:repeat>
</apex:page>
```

The following example uses an Apex class to set the flow to `{!myflow}` and then uses a Visualforce page to run the flow interview. The Visualforce page uses a data table to iterate over the flow’s record collection variable and display the values for each item in the collection.

```apex_code
public class MyCustomController {
   public Flow.Interview.flowname myflow { get; set; }
}
```

```visualforce
<apex:page controller="MyCustomController" tabStyle="Account">
   <flow:interview name="flowname" interview="{!myflow}" reRender="nameSection" />
    <!-- The data table iterates over the variable set in the "value" attribute and 
         sets that variable to the value for the "var" attribute, so that instead of 
         referencing {!myflow.collectionVariable} in each column, you can simply refer 
         to "account".-->
    <apex:dataTable value="{!myflow.collectionVariable}" var="account" 
        rowClasses="odd,even" border="1" cellpadding="4" id="nameSection">
        <!-- Add a column for each value that you want to display.-->
        <apex:column >
            <apex:facet name="header">Name</apex:facet>
            <apex:outputlink value="/{!account['Id']}">
                {!account['Name']}
            </apex:outputlink>
        </apex:column>
        <apex:column >
            <apex:facet name="header">Rating</apex:facet>
            <apex:outputText value="{!account['Rating']}"/>
        </apex:column>
        <apex:column >
            <apex:facet name="header">Billing City</apex:facet>
            <apex:outputText value="{!account['BillingCity']}"/>
        </apex:column>
        <apex:column >
            <apex:facet name="header">Employees</apex:facet>
            <apex:outputText value="{!account['NumberOfEmployees']}"/>
        </apex:column>
    </apex:dataTable>
</apex:page>
```

Depending on the contents of the record collection variable in your flow, here’s what that data table looks like.

![Example of a data table that displays the contents of a record collection variable](https://a.sfdcstatic.com/developer-website/sfdocs/platform/media/salesforce-pages-developers-guide/flow_display_collection.png)
