Multiple Loops in one workflow

Hello,

I’m trying to build a workflow to send notification/escalation emails when a campaign is Overdue. Upon the deadline, I get a list of Reviewers who have yet to complete their review, and then I loop through the list and send an email to them and their manager. The initial Loop for the first notice worked perfectly. The list of reviewers is an array from $.hTTPRequest.body.*.reviewer, and the input for the first step (Get Identity) is $.loop.loopinput.id.

For the second notice, I wait for two days, check that the campaign is still not complete, and then I gather a new list of reviewers who have overdue decisions. When trying to do the second loop, it fails to carry out any of the steps in the loop.
I’m getting this error:

{"error":"json: cannot unmarshal array into Go value of type map[string]interface {} (type: Activity Output Error, retryable: false): json: cannot unmarshal array into Go value of type map[string]interface {}","workflowId":"ea807108-7250-4c54-b780-bf7e9dc0a523-1"}

The second loop gets it’s input from $.hTTPRequest1.body.*.reviewer, and the input for the first step (Get Identity) is $.loop1.loopinput.id

The actual input array looks like this:

"input": [
            {
                "email": "[email protected]",
                "id": "720e9ee28f5c45c6bc21eb302b9e543e",
                "name": "Joe.Smith_admin",
                "type": "IDENTITY"
            },
            {
                "email": "[email protected]",
                "id": "2c9180867f89182d017f990c123705cb",
                "name": "John.Doe_admin",
                "type": "IDENTITY"
            }
        ]

For some reason the first loop accepts the input, but the second doesn’t? Does anyone know if multiple loops in one workflow are not supported? Am I missing something?

First Loop:

Second Loop:

I found this KB Article. It looks like Workflows are limited to one Loop Operator. I’m going to try their suggested workaround though utilizing an external trigger and secondary workflow.

Workflow Limited to One Loop

I am running into similar problem, let me know what workaround worked for you and would appreciate if you can share your workflow json

Hi @sunnyajmera

Believe you need to use nested workflow here. So from the loop of 1st workflow you can call another workflow and then this workflow can call itself recursively if needed. That should do the trick.

Let me know if that helps.

Regards
Vikas.

Thanks for the input, let me try and get back if I need more help.

1 Like