2

I've created a visualforce page that has a "popup" (aka outputpanel that is rendered when the flow is called). This works fine for Flows that don't reference another flow.

I've created a flow that has another flow embedded in it, but it will not show the second flow on my visualforce page. What appears to be happening is when the second flow is called the visualforce page is being called again, thus running the constructor in the custom controller. By default the popup is set to rendered=false, so the second flow never runs.

As part of debugging I've set the popup to always render. I can see the data pass bewteen the inital flow and the one being called. The first three flows work just fine.

All I can think of is to set a flag in an object to indicate that the flow is still active, so when the inital flow calls others the outputpanel continues to render.

<apex:component controller="OrderController" allowDML="true">
  <apex:attribute name="UsrID" description="The id of the contact user for the Meal"
                  type="String" required="required" assignTo="{!UserID}"/>
    <apex:pageBlock id="item">
        <apex:form >
        <table>
           <tr>
               <td width="213" rowspan="2">
                    <apex:image value="{!$Resource.PhotoHolder}"/>                   
                    <h1>{!item.name}-{!Rating}</h1>
                    <p>{!item.description}</p>                   
               </td>
               <td>
                    <apex:commandButton action="{!EditItem}" image="{!$Resource.edit}" reRender="modifier"/>  
               </td>   
               <td>
                   <apex:commandButton action="{!RemoveItem}" image="{!$Resource.decrease}" reRender="Order,item"/>
                   &nbsp;{!if (IsNew,0,orderitem.quantity__C)}&nbsp;
                   <apex:commandButton action="{!AddItem}" image="{!$Resource.increase}" reRender="Order,item,flow" />                   
               </td>   
           </tr>
           <tr>
                <td>
                    {!ModCopy}
                </td>    
           </tr>    
        </table>    
        </apex:form>     
    </apex:pageBlock>  
 <apex:outputPanel id="flow">
    <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!ShowFlow}"/>
    <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!ShowFlow}">
        <!--This is generating an error. Doing a static workaround
        <apex:dynamicComponent componentValue="{!Oflow}" />  -->
        <flow:interview name="OptAssIng" interview="{!OAIFlow}"  rendered="{!ShowModFlow}"/>
        <flow:interview name="SoupSize" interview="{!SSFlow}"  rendered="{!ShowSoupFlow}"/>
        <flow:interview name="BrettsPFlow" interview="{!PFlow}"  rendered="{!ShowPlateFlow}"/>
        <flow:interview name="N_Order_Flow" interview="{!NOFlow}"  rendered="{!ShowOrderFlow}"/>                
    </apex:outputPanel>
</apex:outputPanel>     


<style type="text/css">
    .row {overflow:hidden; position:absolute;}
    .row {left:0; right: 0;}
    .search.row {top: 0 ; height:29px;}
    .menu.row {top:30px; height:40%;}
    .order.row {bottom:0; top:44%;}
    .scroll-y {overflow-y:auto;}
    .custPopup{
        background-color: white;
        border-width: 2px;
        border-style: solid;
        z-index: 9999;
        left: 20%;
        right: 20%;
        padding:10px;
       position: absolute;
       /*   These are the 3 css properties you will need to change so the popup 
        displays in the center of the screen. First set the width. Then set 
        margin-left to negative half of what the width is. You can add 
        the height property for a fixed size pop up if you want.*/
        width: 200px;

        top:100px;
    }
    .popupBackground{
        background-color:black;
        opacity: 0.20;
        filter: alpha(opacity = 20);
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        z-index: 9998;
    }

</style>        

public class OrderController{

    string ItemSearch;
    boolean ShowModifier;
    boolean ShowAdd;
    public boolean ShowCategory {get;set;}
    public boolean ShowFlow {get;set;}
    public boolean ShowModFlow {get;set;}
    public boolean ShowAssMod {get;set;}
    public boolean ShowSoupFlow {get;set;}
    public boolean ShowPlateFlow {get;set;}
    public boolean ShowOrder {get;set;} 
    public boolean ShowOrderFlow {get;set;}
    boolean IsNew;
    list<asset_in_meal__C> MyOrder;
    list<asset> Menu;
    list<AggregateResult> MenuCategories;
    asset Item;
    case Meal;
    asset_in_meal__C OrderItem;
    contact cnct;
    decimal rating;
    string ModCopy;
    public list<assetmodifierWrapper> ModChooser {get;set;}
    public string ModComments {get;set;}
    //public component.flow.interview OFlow {get;set;}
    public flow.interview.OptAssIng OAIFlow {get;set;}
    public flow.interview.SoupSize SSFlow {get;set;}
    public flow.interview.BrettsPFlow PFlow {get;set;}
    public flow.interview.Nepo_Order_Flow NOFlow {get;set;}
    ID UserID;

    public OrderController(){    
        ShowCategory = true;
        ShowModifier = false;
        ShowModFlow = false;
        ShowSoupFlow = false;
       ShowFlow = true;
        ShowPlateFlow = false;
        ShowOrder = true;
        ShowOrderFlow = true;


      }

    void construct(){
        setMenuCategories();

        MyOrder = [select asset__r.name,quantity__c,id,asset__r.id from asset_in_meal__c where meal__r.id = :meal.id];

    } 
public void AddItem(){
  //  system.debug(ApexPages.currentPage().getParameters().get('itmtyp'));
    if (IsNew){          
     orderitem = new asset_in_meal__c(meal__c=meal.id,quantity__c=1,asset__c=item.id);
     insert orderitem;
    // system.debug(orderitem.id);
     IsNew=false;

      system.debug(string.IsNotBlank(item.OrderFlow__c));
      system.debug(item.name+item.orderFlow__c);       
     if (string.IsNotBlank(item.OrderFlow__c)){
            map<string,object> ParmMap = new map<string,object>();
            ShowFlow = true;

            if (item.orderflow__c=='OptAssIng'){
                ShowModFlow = true;

                ParmMap.put('OrderItem',orderitem.id);
                OAIFlow = new flow.interview.OptAssIng(ParmMap);
                /*this is generating an error, doing a static workaround
                OFlow = new component.flow.interview(name = item.OrderFLow__c);*/
            } else if(item.orderflow__c =='SoupSize' || item.OrderFlow__c=='GlassBottle') {
                ShowSoupFlow= true;

                ParmMap.put('AIMIn',orderitem.id);
                ParmMap.put('SizeType',item.orderflow__c);
                SSFlow = new flow.interview.SoupSize(ParmMap);

            } else if (item.orderflow__c.StartsWith ('BYO')) {
                ShowPlateFlow = true;

                ParmMap.put('AccountID',meal.account.id);
                ParmMap.put('FlowName',item.orderflow__c);
                ParmMap.put('MealID',meal.id);
                ParmMap.put('AIMId',item.id);
                ParmMap.put('ParentAIM',orderitem.id);
                PFLow = new flow.interview.BrettsPFlow(ParmMap);

            } else if (item.OrderFlow__c == 'quesa') {
                ShowPlateFlow = true;

                ParmMap.put('FlowName',item.OrderFlow__c);
                ParmMap.put('AIMId','item.id');
                PFLow = new flow.Interview.BrettsPFlow(ParmMap);
            } else  {
                ShowOrderFlow = true;

                ParmMap.put('AccountID',meal.account.id);
                ParmMap.put('FlowName',item.orderflow__c);
                ParmMap.put('MealID',meal.id);
                ParmMap.put('AIMId',item.id);
                ParmMap.put('ParentAIM',orderitem.id);
                NOFLow = new flow.Interview.Nepo_Order_Flow(ParmMap);

            }
        }
        system.debug(ShowModFlow); 
        system.debug(ShowSoupFlow);        
    } else {
        orderitem.quantity__c = orderitem.quantity__c +1;//this will need to go into the nepoOrdering class to look for availability
        upsert orderitem;
    }
     MyOrder = [select asset__r.name,quantity__c,id,asset__r.id from asset_in_meal__c where meal__r.id = :meal.id];              
 // return null;   
}

}

3
  • 1
    It would be helpful if you could share your code so we can see what you are trying to do.
    – JimRae
    May 29, 2014 at 19:48
  • what you are describing sounds like standard visual-workflow functionality. When you enter a flow, or pass between one to another, the page refreshes. This makes it challenging if trying to gather information in an apex:form AND from a workflow, but like @JimRae mentioned, without code it is difficult to offer better comments or answers
    – Tezyn
    May 29, 2014 at 20:07
  • Do you pass the variables as input/output parameters within your flows? And are the variables itself set to input AND output? Apr 20, 2015 at 6:52

2 Answers 2

1

If the issue is related to the page render, I would suggest you add a rerender tag on your interview lines and just update the panel you have the flows running in.

0

Thanks for sharing your code. I'm trying to run it to compose a solution for you. The component code is missing the /apex:component closing tag, so I don't know how much was cut off the end, but it won't save in its current state. There is no code provided for the Visualforce page, and the Class needs some custom objects, e.g. asset_in_meal__c, before it will save. Then, the flows are missing, as well...

Consider reducing your sample to the minimum required to illustrate the problem, and provide the complete package. Short of that, we can only speculate vs. provide a working solution.

1
  • The calling VisualForce page only calls this component, headers and sidebar. The full code is quite large and does incorporate both custom and standard objects. The issue I'm having is flows within flows are not passing data via variables. I'm not sure how to post what the flows are.
    – MarcoC
    Jun 1, 2014 at 10:43

You must log in to answer this question.

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