Avoid Unexpected Results With Branch For Each Step

Last Updated: 10/30/2018 Introduced in Version: 3.2

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.

createFlow

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

nameFlowMain

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

getAllAccounts

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

addBranchForEach

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

defineTypeForBranch

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

defineCollectionForBranch

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

branchConfigured

Next, on the For Each outcome from the Branch step we add Show Form step from the Favorite Steps category.

addFirstForm

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

createFirstForm

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.

formDesign

Then, we select our Form on the workspace and change the Assignment Type from In Session to Assigned.

assignFirstForm

Next, we click Show Mapping Editor for this step.

showMappingEditorForFirstForm

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

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.

addSecondForm

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

assignSecondForm

Then, we click Show Mapping Editor…

showMappingForSecondForm

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

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

addMergeStep

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

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 Shot

debugFlowWithValidation

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

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

firstFormAdmin

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

firstFormAdminDisplayed

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

fillInSecondAdmin

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

secondFormAdminDisplayed

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

loginAsDifUser

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

firstFormVitalii

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

fillInFirstFormVitalii

Next, we expect Second Form with our Email Address to be Assigned to us but this is not happening.

noSecondFormAssignmentVitalii

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 new Assigned Forms… These are the Second Forms that should be Assigned to other Accounts.

adminAccountIsBeingAssignedFirstFormsAgain

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

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

nameLinkedFlow

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

addNewFlowInput

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

defineTypeForAcc

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

addFirstFormLinked

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

Then, we select First Form on the workspace, change Assignment Type to the Assigned and click Show Mapping Editor.

assignFormAndShowMappingFirst

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

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

assignFormAndShowMappingSecond

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

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

linkedFlowCompleted

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

editMainFlow

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

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

We can delete our old Form Steps from the workspace.

deleteFormSteps

Mention, that Branch For Each step does not have Validation Warning. We can test our Flow now. Click Debug link on the Top Panel of the Flow Designer.

debugFlowCompleted

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

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

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

firstFormDifAcc

 

We complete the Form

completeFirstFormDifAcc

 

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

secondFormDifAccAssigned

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

completeSecondFormDifAcc

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

 

 

 

 

Additional Resources