Workflows - Pass a list of attribute values from an account to loop as input

We are using Workflows to populate the end date for credentials for Brivo (application) users. A user can have multiple credentials on the Brivo account.

We are using a workflow which is using the Identity Attributes Change trigger.
Following are the steps.

  1. Get Identity
  2. Get Accounts
  3. Check if the identity has an account on Brivo
  4. Loop through all credentials for the user account on Brivo
    We are using $.getAccounts.accounts.[?(@.sourceName == “Brivo”)].attributes.credentials[*] as the loop input.

The above jsonpath evaluates to

[
  [
    "credential_id1",
    "credential_id2
  ]
]

This is creating an issue in the loop while executing a HTTP request. Inside the loop
$.loop.loopInput evaluates to [[“credential1”]]
$.loop.loopInput[0] evaluates to “credential1” but it just runs one time with first credential. The second credential is ignored.

The output of getAccounts

[
  {
    "attributes": {
      "ADDRESS_LINE_1": "Single Office"
   },
    "sourceName": "Workday"
  },
  {
    "attributes": {
      "credentials": [
        "65718689",
        "12345644"
      ],
      "employeeID": "314507"
    },
    "sourceName": "Brivo"
  }
]

Here’s an approach to your requirement - you would have to create another external trigger workflow and invoke that in the current workflow using Http request action.

  1. In the current workflow instead of loop, perform Http request action and you need to pass $.getAccounts.accounts[?(@.sourceName == "Brivo")].attributes in the Post json request body and end it
  2. In the external trigger workflow, configure loop immediately after trigger and have the loop input as $.trigger.credentials. That way your external trigger loop would invoke twice - once for each credentials, and rest of the actions can
    be performed within the loop.

I think this is a bug caused during latest updates to workflow (here). Even I have noticed this behavior causing issues in iterating through the output in a workflow that was working until 2-3 days ago where reading an array was giving an output like below:

[ 
    "credential_id1",
    "credential_id2
]

ie with just one set of []

1 Like

Please follow Help - HTTP Requests failing with $getAccounts references due to escape characters appearing for an update on this. Others are starting to notice strange behavior as well.

2 Likes

how do we call the external workflow? using the IdentityNow APIs?

we can call external api through Http request action, and the client id, secret and url belongs to the external trigger workflow