Community Announcements have moved! To stay up to date, please join the new Community Announcements group today. Learn more
×Hi there!
I am having a lot of trouble getting the following filter to work.
Context: I am making an API call that returns a list of messages.
I want to filter only the items on the following fields:
- metadata.event_type=“hardCodedString”
- metadata.event_payload.field=“{{value}}” <= value is (supposed to be) a string
A few notes:
- some items do not have a "metadata" field.
- some items do not have the "event_payload.field" field.
Here is the expression I am currently using:
{{#webResponse.body.messages}}
{{#if(equals(metadata.event_type, "hardCodedString"))}}
{{#if(equals(metadata.event_payload.field, value))}}{{ts}}| {{/}}
{{/}}
{{/}}
Since the field “value” is unique (from a business perspective), I should only get one result or none at all.
However, I regularly end up with inconsistent results: items without metadata, items where the event_type does not match, and items where the field value (within event_payload) does not match.
Does anyone have any idea where the problem might be coming from?
Thanks!
Hi @Thibault DUCHATEAU -- Welcome to the Atlassian Community!
There is a known limitation of long-format list iteration where, once inside the iterator, only data from that scope and lower is accessible.
Thus, your value cannot be "seen" inside to perform the filtering. The Atlassian automation team knows about this, and according to other posts, has tried several times to solve this without success. And, there are no built-in, JSON filtering functions for webResponses yet in rules.
Possible workarounds depend upon what you are trying to do with the filtered results:
Kind regards,
Bill
Hello Bill,
Thank you for your welcome, thank you for your time, and thank you very much for your feedback.
The first suggestion based on advanced branch was not possible for me, as I would have been limited in terms of nesting if branches.
The second suggestion was exactly what I needed.
Thank you again!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.