+ Start a Discussion
SkeeterSkeeter 

Visualflow Custom Button and controller

I am trying to create a custom button that will start a visual flow and finish at the list view of that object.  
The VF page does not show as an option to overwrite the new button.  I'm pretty sure this is because I am not using a standard controller.

Any help is greatly appreciated.

Visualforce Page
<apex:page Controller="ExecFinController" TabStyle="BI_Executive_Financial_Dashboard__c">
    <flow:interview name="BI_Executive_Finance_Flow" finishLocation="{!OID}"/>
</apex:page>

Controller
public class ExecFinController {

public Flow.Interview.BI_Executive_Finance_Flow myFlow { get; set; }

public PageReference getOID() { 
  Schema.DescribeSObjectResult result = BI_Executive_Financial_Dashboard__c.SObjectType.getDescribe(); 
  PageReference pageRef = new PageReference('/' + result.getKeyPrefix() + '/o'); 
  pageRef.setRedirect(true); 
  return pageRef; 
}

}

 
Best Answer chosen by Skeeter
@Karanraj@Karanraj
You can use extension concept with the standardcontroller to overcome this problem
 
public with sharing class ExecFinController {

  public ExecFinController(ApexPages.StandardController controller) {

    }
public Flow.Interview.BI_Executive_Finance_Flow myFlow { get; set; }
public PageReference getOID() { 
  Schema.DescribeSObjectResult result = BI_Executive_Financial_Dashboard__c.SObjectType.getDescribe(); 
  PageReference pageRef = new PageReference('/' + result.getKeyPrefix() + '/o'); 
  pageRef.setRedirect(true); 
  return pageRef; 
}
}

Visualforce page
 
<apex:page StandardController="BI_Executive_Financial_Dashboard__c" extensions="ExecFinController" TabStyle="
BI_Executive_Financial_Dashboard__c">
    <flow:interview name="BI_Executive_Finance_Flow" finishLocation="{!OID}"/>
</apex:page>

 

All Answers

@Karanraj@Karanraj
You can use extension concept with the standardcontroller to overcome this problem
 
public with sharing class ExecFinController {

  public ExecFinController(ApexPages.StandardController controller) {

    }
public Flow.Interview.BI_Executive_Finance_Flow myFlow { get; set; }
public PageReference getOID() { 
  Schema.DescribeSObjectResult result = BI_Executive_Financial_Dashboard__c.SObjectType.getDescribe(); 
  PageReference pageRef = new PageReference('/' + result.getKeyPrefix() + '/o'); 
  pageRef.setRedirect(true); 
  return pageRef; 
}
}

Visualforce page
 
<apex:page StandardController="BI_Executive_Financial_Dashboard__c" extensions="ExecFinController" TabStyle="
BI_Executive_Financial_Dashboard__c">
    <flow:interview name="BI_Executive_Finance_Flow" finishLocation="{!OID}"/>
</apex:page>

 
This was selected as the best answer
SkeeterSkeeter
Thank you so much for the help!