How to get back dynamic content after ‘Filter array’ in Power Automate
Posted On January 17, 2021
“I don’t see the dynamic content output from the Power Automate ‘Filter array’ action, all I see are the values from the action before the filter was applied.”
‘Filter array’ is a Power Automate action you use if you can’t filter directly in the ‘Get…’ action. If the OData Filter query is not available or can’t be used for any reason, ‘Filter array’ is the action to use instead. But there’s a small problem with this action: it doesn’t keep the schema of the original array. It doesn’t matter how many dynamic content values the original array had, ‘Filter array’ might reduce them to two. It’ll display only ‘Body’ (the filtered array) and ‘Item’ (the objects themselves). How can you use the values from the filtered array then?
Add ‘Parse JSON’ to rebuild the schema
The simplest way is to add back the array schema using the ‘Parse JSON’ action. As already described in a previous post, take the ‘Filter array’ output and use it as the sample JSON payload. Power Automate will create a schema from the sample automatically. Then just input the ‘Body’ output into the action Content.
The dynamic content will be available again as the output from the ‘Parse JSON’.
I consider ‘Filter array’ one of the key actions in Power Automate. I believe you should always filter instead of using conditions, but not all Power Automate actions allow you to use OData Filter query. Sometimes you must get all items and filter them later, e.g. when working with MS Teams or Planner. Or when filtering by an unsupported column in SharePoint, e.g. multiple lines of text.
But don’t let the missing dynamic content force you to replace the ‘Filter array’ with a ‘Condition’. If it’s not available, add the ‘Parse JSON’ action and create the schema again.