Avoid Unexpected Results With Branch For Each Step
  • Updated on 25 Nov 2015
  • 7 minutes to read
  • Print
  • Dark
    Light

Avoid Unexpected Results With Branch For Each Step

  • Print
  • Dark
    Light

This tutorial demonstrates how to avoid unexpected results while using Branch For Each step.
Example:
In this example we are going to demonstrate unexpected results that may occur using Branch For Each step. Then, we are going to demonstrate how to avoid these unexpected results.
We begin in the Designer Folder by clicking Create Flow on Folder Actions Panel.
createFlow21.png

Then, we Name our Flow and click Create to proceed to the Flow Designer.
nameFlowMain.png

First, in the Flow Designer we add Get All step from the Integrations > All Integrations > Account Service category.
getAllAccounts.png

Then, next to Get All step in our Flow we add Branch For Each step from All Steps [Catalog] > Flow Management category.
addBranchForEach.png

In the resulting window we define Account Type for the Branch For Each step.
defineTypeForBranch.png

After we have defined Type , we should be able to define Collection Input for the Branch For Each Step . We Select Value of theGetAll_Output.
defineCollectionForBranch.png

When Branch For Each step configured, we can click Done .
branchConfigured.png

Next, on theFor Each outcome from the Branch step we addShow Form step from the Favorite Steps category.
addFirstForm.png

In the resulting window we Name our Form and click Create to proceed to the Form Designer.
createFirstForm1.png

For the simplicity of this example we designed our Form as following… We have a Label that is configured as Variable and a Button to complete the Flow . When finished, we can save the Form and close Form Designer.
formDesign12.png

Then, we select our Form on the workspace and change the Assignment Type fromIn Session to Assigned .
assignFirstForm.png

Next, we click Show Mapping Editor for this step.
showMappingEditorForFirstForm.png

In the Mapping Editor we expand Item outcome from the Branch For Each step and connect AccountID to AccountsAndGroups and DataToDisplay fields. So for each account in the System we are going to assign a Form that displays its Account ID . When finished, we can save and close Mapping Editor.
mappingForFirstForm.png

Then, we are going to add another copy of the Form that we created in previous steps next to the first Form in our Flow .
addSecondForm3.png

We change the Assignment Type on the second Form to Assigned .
assignSecondForm.png

Then, we click Show Mapping Editor…
showMappingForSecondForm1.png

In the Mapping Editor we expand Item outcome from the Branch Step and map data as following. This Form is going to be Assigned to the same account as first Form but will display Email Address instead of AccountID . When finished, save and close Mapping Editor.
mappingForSecondForm.png

Back in the Flow Designer we add Merge Step from the All Steps [Catalog] > Flow Management category.
addMergeStep.png

Mention, that our Branch Step has a validation warning that says that we should encapsulate all steps between Branch and Merge steps into a Linked Flow . If we ignore this warning, we may end up with unexpected results.
validationOnBranch.png

Let’s Debug our Flow to see the results…
Note that in Decisions version 3.5 and above, you'll need to click Test Flow rather than Debug Flow .
3.5-Test-Flow-Shot12.png

debugFlowWithValidation.png

The Flow runs in the Debugger and first Form is being assigned to our current account. In the pop-up window we click No to ignore the Assignment .
firstFormAssigned.png

In the Home Folder we can find the first Assigned Form . We click it and choose to Fill It In.
firstFormAdmin.png

The Form displays our Account ID and we submit this by clicking Done .
firstFormAdminDisplayed.png

Second Form is being assigned to us, and we click Yes to Fill In The Form .
fillInSecondAdmin.png

Second Form displays our Email Address as expected. Click Done to complete the Assignment .
secondFormAdminDisplayed.png

Then, we Log Out and Log back in as a different user.
loginAsDifUser.png

In the Home Folder we locate First Assigned Form and Fill It In.
firstFormVitalii.png

Again, as expected, our Form displays our Account ID . We click Done to submit.
fillInFirstFormVitalii.png

Next, we expectSecond Form with our Email Address to be Assigned to us but this is not happening.
noSecondFormAssignmentVitalii.png

We test another Account and see the same behavior… First Form is Assigned . After First Assignment completion Second Form is not being Assigned . We go back to the initial account… In the Home Folder we can see two newAssigned Forms … These are the Second Forms that should be Assigned to other Accounts .
adminAccountIsBeingAssignedFirstFormsAgain.png

Next, we are going to fix this issue by encapsulating our Forms into a Linked Flow.
In the Designer Folder we click Create Flow on the Folder Actions Panel.
createLinkedFlow.png

Then, we Name the Flow and click Create to proceed to the Flow Designer.
nameLinkedFlow.png

In the Flow Designer we select Start Step on the workspace and click Add New Flow Input.
addNewFlowInput.png

We know, that both our Forms need to use Item (Account) output from theBranch Step. Therefore, we add a variable of Account type as Flow Input.
defineTypeForAcc.png

Then, we simply add our Form from the Flows, Rules, Forms, and Reports > Forms [Interaction] > [Current Folder] category.
addFirstFormLinked.png

Next, we add another copy of our Form next to the First Form in the Flow . Connect the outcome from the Second Form to the End Step in the Flow .
addAnotherForm.png

Then, we select First Form on the workspace, changeAssignment Type to the Assigned and click Show Mapping Editor.
assignFormAndShowMappingFirst.png

In the Mapping Editor we map data in the same manner we did in the Main Flow for the First Form but here we are using Account Flow Input instead of Item . Save and close Mapping Editor when finished.
firstLinkedMapping.png

Next, we select Second Form on the workspace, change Assignment Type to Assigned , and click Show Mapping Editor.
assignFormAndShowMappingSecond.png

In the Mapping Editor we expand Account Flow Input , connect Account ID to Accounts and Groups field, and Email Address to the Data To Display field. Save and close Mapping Editor.
mappingForSecondLinked.png

This completes our Linked Flow . Save the Flow and close Flow Designer.
linkedFlowCompleted.png

Back in the Designer Folder we locate our Main Flow and Edit it.
editMainFlow.png

In the Flow Designer we remove connections To and From our Form steps. Then, on the For Each outcome path from the Branch For Each step we add our Linked Flow from the Flows, Rules, Forms, and Reports > [Current Folder] category.
addLinkedFlow.png

Then, connect Done outcome from the Linked Flow to the Merge Step . Select Linked Flow Step and Select Value of Item outcome from the Branch Step as Account Input to this step.
mappingForLinkedFlow.png

We can delete our old Form Steps from the workspace.
deleteFormSteps.png

Mention, that Branch For Each step does not haveValidation Warning . We can test our Flow now. Click Debug link on theTop Panel of the Flow Designer.
debugFlowCompleted.png

Our Flow runs in the Debugger and just like the first time First Form is being Assigned to us and we ignore it by clicking No .
firstFormAssignedToAdmin.png

Then, we navigate to the Home Folder , locate the First Assigned Form and Fill It In … The Second Form is being Assigned to us after we Complete First Form … We fill in the Second Form.
secondRunFirstForm.png

Then, we Log Out and Log back in as different User . In the Home Folder we locate First Assigned Form andFill It In
firstFormDifAcc.png

We complete the Form
completeFirstFormDifAcc.png

And Second Form is being Assigned to us right away as expected.
secondFormDifAccAssigned.png

Second Form displays our Email Address … We click Done to complete the Assignment .
completeSecondFormDifAcc.png

When we log back in as initial Account , we can see that our Flow Assigned all Forms as we designed and no unexpected results present.
noUnexpectedResults.png

Was this article helpful?