1
0
-1

I have a simple Async Subflow that accepts in a couple workflow variables using the "In and Out" option.  The Variable values are successfully passed to the SubFlow, but when the Subflow finishes, the updated values are not passed back to the parent process.  

Attached you will find a simple application to demonstrate the issue.  APP_testSubFlow-1-20171113221419.jwa

  • Click the Run Process button
  • Check the Field 1 checkbox and enter "my value" in Field2
  • Click Complete
  • Find the record in the Datalist, and click the "Subflow Activity 1" link (this is for the subflow)
  • Uncheck Field1 and enter "my new value" into Field2
  • Click Complete
  • Find the record in the Datalist, and click the "Activity 2" link (this is for the parent flow)
  • Notice that Field1 and Field2 still have the original values.  
  • If you look at the form table (app_fd_SubFlowTest) you'll see that the updated values are there
  • If you look at the process in the Running Processes admin tool, you'll see that the worflow variables were not updated.  

Is there a way to make this work?

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      As Anders mentioned, this doesn't work with Async subflows.  If anyone is interested, I was able to accomplish this with a combination of Async subflows and Bean Tools.  I have a Bean Tool in the parent flow that puts the parent ProcessId in a workflow variable:

      import org.joget.workflow.model.service.*;
       
      WorkflowManager wm = (WorkflowManager) pluginManager.getBean("workflowManager");
      wm.activityVariable(workflowAssignment.getActivityId(),"wfProcessId", "#assignment.processId#");

      The `wfProcessId` is passed into the subflow as an IN variable.  

      Then I have a Bean Tool as the last step in the Async SubFlow that passes the workflow variables that were set in the subflow, back up to the parent flow.  

      import org.joget.workflow.model.service.*;
      import java.lang.Exception;
      import org.joget.commons.util.LogUtil;
      
      WorkflowManager wm = (WorkflowManager) pluginManager.getBean("workflowManager");
      
      wm.processVariable("#variable.wfProcessId#", "wfParentFlowVariableName", "#variable.wfSubFlowVariableName#");

      If there's an easier way to do this, please let me know. 

      Thanks!

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi, found a working example at Sample Application with Subflow. I think it could be because your subflow execution is asynchronous, in which case the process continues without waiting for the results of the subflow.

        1. Seth Klock

          Thanks Anders . That's what I found as well. I should have mentioned that switching it to Synchronous works fine. The problem is that I need an async subflow. Is there a way for an async subflow to interact with the workflow variables of the parent process? I guess I could do this with something like the [Multiple Approval](https://dev.joget.org/community/display/KBv6/Multiple+Approval) example, but I was hoping to be able to use the subflow framework. Thanks

        CommentAdd your comment...