07-25-2024 03:03 AM
Hey all,
I have used the Python action to output a list, I've provided the schema and I can iterate over it without issue. However, what I would like to do is filter the list before iterating over it. So for example, the list contains an ID field, I can use .where(id: 123) to get just the hashes/objects I want. Problem is, I don't understand how I can use the output of my formula in my recipe. The input for the for each mode doesn't accept a formula, and I can't seem to find a way to update a variable. The only option I'm seeing right now is to make it part of my Python step, but I'd really prefer to use the built in functionality.
This maybe clearer, I want to filter 'user group reference' by the ID before passing it into the for each.
Does anyone know how I can approach this?
Solved! Go to Solution.
07-25-2024 07:28 AM
I've often been frustrated by this scenario too. You may want to upvote this idea:
https://ideas.workato.com/app/#/case/187864?currentProductId=caf1efdf-1d7e-4b7b-aeb9-28e4b0f4b25c
The weird workaround I've used and heard from others is to use a Logger step where you do your .where function, then use a JSON parsing step where you enter a sample document (based your existing schema) and use your Message output and apply the .to_json formula on it. Now you have a List that you can iterate over.
07-25-2024 07:28 AM
I've often been frustrated by this scenario too. You may want to upvote this idea:
https://ideas.workato.com/app/#/case/187864?currentProductId=caf1efdf-1d7e-4b7b-aeb9-28e4b0f4b25c
The weird workaround I've used and heard from others is to use a Logger step where you do your .where function, then use a JSON parsing step where you enter a sample document (based your existing schema) and use your Message output and apply the .to_json formula on it. Now you have a List that you can iterate over.
07-25-2024 08:59 AM
This is the way (but you could skip the logger step and do the .where on the input to the JSON parser action).
Gotta save those tasks! 😛
07-25-2024 09:15 AM
Heh, true enough. Task task task. Though for bulk actions like this outside of a loop, sometimes I'll eat the task just for the sake of knowing the results step-by-step for future troubleshooting purposes.