Hi,
I have a flow that gets data via an HTTP step.
The output includes several fields where my interest is in two fields: URL, and group ID:
I have an excel and in the excel I have a column with the URL.
I want to check in the JSON the URL from excel and if it finds it to receive the group ID and if not to do something else.
I'll really appreciate it if someone can help me.
The Filter array will contain all the properties from your JSON including the groupId.
@grantjenkins amazing, thank you.
Just a little question from where do you take the group ID
in
first(body('Filter_array'))?['groupId']
I'd suggest using a Filter array on the locations array in your JSON.
In my example I've assumed you are looping over each of the rows in your Excel file.
See my example below. I'll go into each of the actions.
Compose just contains a sample of your data you retrieve from HTTP. And Parse JSON gets me nice properties I can refer to. You can skip these steps as you already have your data.
List rows present in a table gets my Excel data.
My Excel data for this example has the following:
Next, I use an Apply to each to iterate over each of the rows from Excel. I then have a Filter array that takes in the locations array from my Parse JSON action and filter on url is equal to Location (from the current row)
This will return a filtered array of objects where the url matched. We can then use a Condition to check if the length of the Filter array is greater than 1, and apply the appropriate actions for true or false.
The expression to get the length of the array is:
length(body('Filter_array'))
If you then wanted to extract out the group Id from the Filter array you could use a first expression as we assume it's only returned a single result, but still an array.
first(body('Filter_array'))?['groupId']
Hope that helps and is what you were after.
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional