Hello,
I need to map a sprint name -which is matching a specific string value- to its corresponding Id:
1. First, I get all sprints in my board: /jira/rest/agile/1.0/board/boardid/sprint
Example of the webhook body:
{id=163608, self=xxx, state=closed, name=Sprintname1, startDate=xx, endDate=xx, completeDate=xx, activatedDate=xx, originBoardId=boardid, synced=false, autoStartStop=false}, {id=163650, self=xx, state=closed, name=Sprintname2, startDate=xx, endDate=xx, completeDate=xx, activatedDate=xx, originBoardId=boardid, synced=false, autoStartStop=false}
2. Now I'm trying to filter through the webhook body to extract a certain sprint id only. However I'm facing issues with the filtering query.
If I use this query: {{#webhookResponse.body.values}}{{name}}={{id}}, {{/}}
I get following output: Sprintname1=163608, Sprintname2=163650, Sprintname3=163641...
However I need to only print the Id of the Sprint which is matching a certain string value in its name.
e.g Sprintname2 = R44/23:
Output I need: 163650
I tried a few things, but nothing worked so far:
{{#webhookResponse.body.values}}{{#if(name,"R44/23")}}{{id}}{{/}}{{/}}
{{#webhookResponse.body.name}}{{#if("R44/23")}}{{id}}{{/}}{{/}}
{{#webhookResponse.body.values.name}} {{#if("R44/23")}} {{webhookResponse.body.values.id}}{{/}}{{/}}
Does anyone have an idea what could be wrong with above queries?
Hello @Patrizia Heinzl
You are missing equals keyword in your first query.
{{#webhookResponse.body.values}}{{#if(equals(name,"R44/23"))}}{{id}}{{/}}{{/}}
Awesome, thank you so much! I tried a few variants with equals but never got it to work. This one works! Thank you very much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great. I recall your other thread around the same topic.
Just to add, in this case you have hard coded R44/23 for the lookup, so it worked, but if you want to pass a smartvalue / variable in its place, maybe from the trigger issue, it will not work as in the context of the list iteration, smart values / variables dont resolve.
If you need to extract ID based on variable look up, you need to save this webhook response in a variable and use a regex match to extract it.
Hoping I havent confused you and if what I am talking about does not apply, please ignore.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah thank you. Yes indeed I just tried a smart value and it does not work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But how do I get the regex match with the id?
So you mean to create a variable out of the original webhook, correct?
And on this webhook use the regex match?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you in Cloud edition or Data Center Edition?
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.
Sorry, Regex matching is black magic to me.
But you dont need to save it to a variable, I misspoke earlier. You can operate on the webhook response directly if needed... please see below thread for pointers. There maybe better posts, was just the first hit I found.
I think other folks maybe more experts who can help guide such a look up behavior.. so after researching, maybe posting another thread will help.
Reason I asked if DC or Cloud was.. In cloud, Jira has native branching which lets us do this For/Each check and we dont have to iterate manually like you did.. so Cloud would have been straight forward. DC is the tricky one, unfortunately.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, thank you. Seems there is again an issue because I cannot match a smart value with a smart value :-( But thank you for your quick help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you wont mind, I will pitch my "not good" solution again from other thread.
If you were to create a task (for example) and just assign all open sprints to this one task and you cancel this task immediately, so It wont show up in any board view or backlog.. It will solve the problem of making web request call to get sprint IDs.
Because then, In your rule, after your trigger, you can do a lookup with JQL as.. Sprint = "Fix Version". This will return the canceled Task and you immediately have access to that Sprint ID.
Solves the problem without needing to go through complicated web request route,, when you look at the board, this canceled story wont show up so no one will be any wiser.
Of course I know this is the not the right way but an option in back pocket.
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.