cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

For Each Loop only loading in the final record in a Values array from a HTTP Get Request

PhilipMasters
Deputy Chef II
Deputy Chef II

I have a HTTP Request that successfully retrieves some data and the format looks something like:
{
"Response": {
"_odata.context": "TEST",
"Value": [
{
"C1_ORGANIZATION_ID": "TEST0",
"C2_DESCRIPTION": "TEST0",
"C3_REQUEST_SLA_TEMP_ID": "TEST0",
"C4_CREATED": "TEST0"
},
{
"C1_ORGANIZATION_ID": "TEST1",
"C2_DESCRIPTION": "TEST1",
"C3_REQUEST_SLA_TEMP_ID": "TEST1",
"C4_CREATED": "TEST1"
},
{
"C1_ORGANIZATION_ID": "TEST2",
"C2_DESCRIPTION": "TEST2",
"C3_REQUEST_SLA_TEMP_ID": "TEST2",
"C4_CREATED": "TEST2"
},
{
"C1_ORGANIZATION_ID": "TEST3",
"C2_DESCRIPTION": "TEST3",
"C3_REQUEST_SLA_TEMP_ID": "TEST3",
"C4_CREATED": "TEST3"
},
{
"C1_ORGANIZATION_ID": "TEST4",
"C2_DESCRIPTION": "TEST4",
"C3_REQUEST_SLA_TEMP_ID": "TEST4",
"C4_CREATED": "TEST4"
},
{
"C1_ORGANIZATION_ID": "TEST5",
"C2_DESCRIPTION": "TEST5",
"C3_REQUEST_SLA_TEMP_ID": "TEST5",
"C4_CREATED": "TEST5"
}
]
}
}


I then have a for each loop that loops through this Values array, I then perform a Search to Creatio and then Create/Update accordingly. However, for whatever reason only the final item in this array is actually Updated/Created in Creatio (I am only mapping the fields ORGANIZATION_ID and DESCRIPTION). 
It would seem that the Values array is being accepted and iterated through correctly as my output when testing the recipe is:

{

  • Index: 5,
  • Is first: false,
  • Is last: true,
  • Item: {}

}

However, none of these items are currently in Creatio and so the first four items should be being Created but for whatever reason they aren't. It has nothing to do with the item itself because if I change the ordering it's always only the last item being Created/Updated regardless of the values used. 

3 REPLIES 3

PhilipMasters
Deputy Chef II
Deputy Chef II

I should add that within the recipe flow, within the For Each loop, I have two IF branches to determine whether or not this should be a Create or an Update action.

PhilipMasters
Deputy Chef II
Deputy Chef II

Sorry, actually what's happening in the output of a Test is that the input to the Update is actually the first item in the For Each but the For Each Loop output is Index 5. So clearly the first item goes through the logic inside the For Each loop, the loop continues to iterate but isn't processing the records.

PhilipMasters
Deputy Chef II
Deputy Chef II

Anyone who lands here I was being stupid. Make sure to use the data pill from for each not from http request lol.