Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Filtering a webresponse body by date

Rudy Holtkamp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 10, 2024

Hi,

I've question about Jira automation, particularly filtering data from a webresponse.

I've the following response in a smart value {{webResponse.body}}:

{
"props": [{
"prop": "AA",
"planAs": "0"
},{
"startDate": "2024-06-10",
"prop": "BB",
"planAs": "0"
}, {
"startDate": "2024-11-01",
"prop": "CC",
"planAs": "0"
},{
"prop": "DD",
"planAs": "0"
},{
"startDate": "2023-09-03",
"prop": "EE",
"planAs": "0"
},{
"startDate": "2024-07-28",
"prop": "FF",
"planAs": "0"
},{
"startDate": "2024-07-28",
"prop": "GG",
"planAs": "0"
},{
"startDate": "2023-09-03",
"prop": "HH",
"planAs": "0"
},{
"startDate": "2023-06-10",
"prop": "II",
"planAs": "0"
},{
"startDate": "2024-06-11",
"prop": "JJ",
"planAs": "0"
},{
"startDate": "2024-06-21",
"prop": "KK",
"planAs": "0"
},{
"startDate": "2024-12-31",
"prop": "LL",
"planAs": "0"
}]
}

I want to filter out all props that either don't have a startDate (in this case AA & DD) or all props that have a startDate before and including today (which is now June 10th 2024, but this is of course variable) which wil result in BB, EE & II

How can I do this, using smart value conditions or a regex?

By creating a variable props with smart value {{webRespons.body.props}} and using a new variable myProps with smart value {{props.match("\{.*?prop=(.*?), planAs=\d\}, ")}} 
I get all the props, but I really need only the ones with a startdate of today or before.

 

1 answer

0 votes
Kalyan Sattaluri
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 10, 2024

Hello @Rudy Holtkamp 

If this response is valid JSON which Jira will let us parse,

Then, after your web request call, can you try to do Advanced Branching on smart value {{webResponse.body.props}} and variable =myprops,

You should be able to access {{myprops.startDate}} and do if condition that {{myprops.startDate.jiraDate}} greater than {{now}} then capture your prop in variable?

Rudy Holtkamp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 10, 2024

The problem with using an advanced branching, that it does not wait until it has been executed. So if I try to catch it in a variable in the branch, the rest of the automation rule continues without having the correct value of the variable.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events