Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hello. Trying to use automation to get the Component Lead for a specified Component.
I have a web request returning all project components. And I can iterate through them to display any attribute - using a log action with a statement like this:
{{#webResponse.body}} id: {{id}}, Name: {{name}} :: {{/}}
This returns a list of id and name pairs for each component.
But I'm clearly misunderstanding something because I cannot figure out how to compare values while I iterate the list. When I find a match I want to get the component lead accountId for that specific component. I've tried so many variations now I'm not sure I remember them all - here are a sample:
{{#webResponse.body}}{{if(equals({{name}},"abc"), id: {{id}})}}{{/}}
{{#if(equals({{webResponse.body.name}}, "abc")}} id: {{webResponse.body.id}} {{/}}
This statement: {{#if(equals({{webResponse.body.id}}, 10060))}} "hello"{{/}}
generates this error:
Error rendering smart-values when executing this rule:
Hi @ian ,
as far as I get the documentation right the smart values within the if/equal are without {{}}.
Please try the following approach and let me know if this works:
{{#if(equals(webResponse.body.id, 10060))}} "hello"{{/}}
Best
Stefan
Apologies for the delayed response. Thanks for pointing that out @Stefan Salzl Often takes a fresh pair of eyes to see the obvious mistake.
Unfortunately, while no errors, the command you suggested does not output anything. I also tried "10060" in case it was being treated as a string. Same result - no output.
But adding the iteration before the if statement and putting the "hello" in the then part of the if statement does output "hello":
{{#webResponse.body}}{{if(equals(id,"10060"), "hello")}}{{/}}
Replacing "hello" with the id field reference outputs the id value:
{{#webResponse.body}}{{if(equals(id,"10060"), id)}}{{/}}
Extending this I added a create variable action using this statement as the smart value:
{{#webResponse.body}}{{if(equals(id,"10060"), lead.accountId,)}}{{/}}
An audit log action following this shows that the variable got assigned the correct value.
I think I can now use this as part of my automation to automatically assign requests to the component lead which is what I was ultimately trying to do.
Thanks again @Stefan Salzl
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
AWESOME work man 🥰💪🏼🎉
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Stefan Salzl @ian Thanks for this post! it rescued my code.
I am stuck again :)
JSON structure:
Got a valid web response, parsed it. now the goal is returning id the is marching name
this statement doesn't work (Smart variable - no error is given):
{{#webResponse.body.values}}{{if(equals(name,sprintFromCommentFiltered),id)}}{{/}}
Bus Hard coded:
{{#webResponse.body.values}}{{if(equals(name,"SAT Sprint 1"),id)}}{{/}} is working and returning the id as expected
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kaysaff Tal
Could you please explain what you are trying to achieve from a functional/use case perspective? Without knowing any context it‘s hard to understand and/or find an appropriate solution.
Furthermore could you please share your automation rule?
and one more question:
where does „sprintFromCommentFiltered“ come from? Did you try to output this value to the audit log? Does it deliver the correct value you‘d like to compare against?
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Stefan Salzl Sure thing.
I am send web request to our Jira instant and receiving back data on all sprints in a specific board.
response looks like this
The sprint name Comes from a comment:
Which I parse:
Then trying to get the Matching SprintID
This works fine:
{{#webResponse.body.values}}{{if(equals(name,"SAT Sprint 1"),id)}}{{/}}
When i try to use the variable it fails
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kaysaff Tal
It seems to me the problem is as soon as you start iterating over the webresponse the context within will always be the webresponse. So your variable would always try to resolve within the context of the webresponse (where there is no „property“ with that name). So to say (as far as I got it) the ouside variable could not resolve inside an iteration over a different object.
Have you tried to put the webresponse into a branch? You could do a forEach branch that will also iterate over your webresponse and you could control the required action via comparison in an if-condition (where you could use the variables smart value).
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Stefan Salzl Not sure what u mean:)
I think the Object is fine my issue is
this command:
where teste wquals
but when it runs hard coded:
the corrspondin ID is retuned,
The question if equals can identify variables i guess
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What I meant in my previous post:
- create an advanced branch to iterate over your webresponse (see screenshot):
- then add an advanced compare condition to compare the current iteration index against your created variable (in this case it´s possible to use a variable from outside of the branch which i guess is not possible when iterating over a smartvalue) - see screenshot:
- according to the if-comparison-condition the log action only fires when it´s true. so in my example above even if the branch iterates over all the sprints (which are about 9 in my example) the log action fires once.
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Stefan Salzl Thank u so much for the help here.
The issue is not finding the Sprint Name. is extracting corresponding sprintID.
that is the issue i am stuck with
any thoughts? what i am missing?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kaysaff Tal
- This is the variable create upfront (in your case this would be what you extract from your issue´s comment - i just hardcoded the string in the variable)
- changed the branch to name "sprint" and it iterates over the values of the webresponse. This is capsulated in the name "sprint" that can be used as smart value in the branch:
- the condition then does the comparison of the current iterations SprintName against your variable (comment from issue):
- only if this matches I fetch the id from the webresponse. As my webresponse is capsulated in the variable "sprint" (configured in the branch configuration) I only add {{sprint.id}}
- wich results in the following:
Hope this describes what you are searching for.
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Stefan Salzl This is Amazing Solution!!!
it works perfectly!!! Alod understood how to use smart values in the process of trying to get this to work :)
One last struggle :)
after I branch out to the Smart Value:
Clone the specific story, assign it to the sprint we just found and move the Sub tasks that are still open.
Challenge: There is no branch out to cloned issue subtasks in the smart value branch
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kaysaff Tal
I dunno the whole use case behind it and furthermore the comunity is not a place posting requirements and get complete solutions but guiding you in a problem situation when you get stuck.
The main question was how to compare the result of a webresponse. As it seems for me this could be solved.
Furthermore:
(Talking as an experienced Scrum Master and Agile Coach) It seems you would like to clone open Stories from one sprint to another one. Why would you do that and not take the open story into the next sprint (which is commonly done and from my perspective the better way).
And technically moving the subtasks would mean a "Move issue" action which neither A4J nor RestAPI is capable of.
Best
Stefan
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.