1

I've created a custom List button on the Opportunity. When clicking the button, the user is redirected to a VF page that invokes a custom flow from a custom controller. The flow works properly on its own, however, when I try to invoke it using the custom button, it states I need to enter a website and country (which are required in the flow). However, these 2 fields are already populated on the Account record. Does anyone know why the flow is not recognizing them through the controller?

VF Page:

<apex:page standardController="Opportunity" tabStyle="Opportunity" Extensions="OpptyFlowController" recordSetVar="opportunities">
    <flow:interview name="Create_Opportunity_w_Parent_Fixed" finishLocation="/p/opp/SelectSearch?addTo={!opportunity.Id}&retURL=%2F{!opportunity.Id}"/>
</apex:page>

VF Controller:

public class OpptyFlowController {

      public ApexPages.StandardSetController stdControl{get; set;}
      public OpptyFlowController(ApexPages.StandardSetController controller) {
          stdControl = controller;
      }

      public Flow.Interview.Create_Opportunity_w_Parent_Fixed OppFlow { get; set; }

        public String getOppID() {
          if (OppFlow==null) return '';
          else return OppFlow.OpportunityId;
        }

      public PageReference getOID(){
        PageReference p = new PageReference('/p/opp/SelectSearch?addTo=' + getOppID() + '&retURL=%2F' + getOppID());
        p.setRedirect(true);
      return p;
      }

    }

1 Answer 1

1

You need to pass them as attributes to the interview from the Visualforce page.

<apex:page standardController="Opportunity" tabStyle="Opportunity" Extensions="OpptyFlowController" recordSetVar="opportunities">
<flow:interview name="Create_Opportunity_w_Parent_Fixed" finishLocation="/p/opp/SelectSearch?addTo={!opportunity.Id}&retURL=%2F{!opportunity.Id}">

 <apex:param name="vaCountry" value="{!Opportunity.Country}"/>

 </flow:interview>
</apex:page>
8
  • Thanks. I made those changes but I'm still having the same issue. Do I need to somehow pass the Account ID first?
    – John N.
    Commented Mar 19, 2015 at 20:08
  • Are you passing in both of the required attributes? Are these required for the first element in your flow? Could you add a screen shot of the error message you are getting?
    – JimRae
    Commented Mar 19, 2015 at 22:11
  • There's not a system generated error message, it's a message generated from one of the screen components of the Flow after a decision component: 'Please go back to the account and provide a Website and Country before continuing this flow.' The List button that calls the VF page and controller above is created in the Opportunity object, but sits on the related list of the Account. I think what's happening is that the VF page is not pulling through the Account ID so none of the information is being recognized. I'm just not sure how to pull the ID in my controller. Any ideas on that?
    – John N.
    Commented Mar 20, 2015 at 13:08
  • You need to do a lookup on any object you are going to reference in the flow. If those elements are required on the account, you could pass the accountID into the flow as an input param, then do a fast lookup on it. When you do, make sure you include any fields that are required for your flow. IF you are manipulating the Opportunity, you could do the lookup on that, and include the accountID as one of the fields, then, in another step, do the account lookup referenced before.
    – JimRae
    Commented Mar 20, 2015 at 13:43
  • Thanks. Can you give me an example of how I would pass the AccountId to the flow?
    – John N.
    Commented Mar 20, 2015 at 15:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .