Hi,
I have a variable {{X}} with a list of strings.
Given a smart value {{Y}} (string), I need to find whether there is a matching value in the list X AND its position.
I know how to iterate X and check if Y matches any element, but I don't know how to get the index with the match.
if there is a matching, the idea is then to do {{X.get(index+1)}} and to handle the case when index+1 is out of bound.
Thanks for your help!
NOTE: I am trying this:
Result: {{#NombresdeTareas}} {{#if(equals({{.}}, issue.summary))}} {{index}} {{/}} {{/}}
but fails with this error:
Just to confirm, is your {{X}} a created variable or an issue field? If it is a created variable, you would need to split it into a list before it can be iterated upon.
For the other part of your question, I am assuming you are using a created variable...
Created variables are text, and have no object type or attributes. And so when split a value is just the {{.}} as you have shown. However that cannot be referenced in the smart value functions. Instead many of the functions are implemented to handle that case without passing the value.
For example...
A complication in your scenario is that once inside of an iterator, only data at that scope and below is visible. That means that for your iteration on NombresdeTareas, the issue summary is not visible.
One work-around for that is to use the match() function with a regular expression on the variable instead of a conditional inside of the iterator:
{{varMyVariable.split(",").match("(blue)")}}
If you do need the index value from the list, would need to store the index with the value, and include that in your match expression.
Kind regards,
Bill
Hi @Bill Sheboy
ust to confirm, is your {{X}} a created variable or an issue field? If it is a created variable, you would need to split it into a list before it can be iterated upon
It's a created variable.
A complication in your scenario is that once inside of an iterator, only data at that scope and below is visible. That means that for your iteration on NombresdeTareas, the issue summary is not visible.
Yes, I found out that. I got an exception error when using issue.summary in the iterator. Any hope for that limitation to get fixed in the future? It's a very bad thing not being able to use any issue fields inside an iterator.
If you do need the index value from the list, would need to store the index with the value, and include that in your match expression.
So your saying red-1,green-2,blue-3,alpha-4 right? Can use match with a list? I don't see that option here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/
Thanks a lot for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried your suggestion but seems that I can't use issue.summary inside the match. The idea is to match the current issue summary againts a list of predefined issue summaries, so I can create the next issue in the list.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am just a Jira user, and so have no visibility to Atlassian changing the scoping behavior for iterators.
Regarding using the index values with the list, first you build the list with an iterator storing in a variable, as you showed for my example. Then match on the value, such as "(blue*)". And finally separate out the value with text functions to get your index.
On your next post about using a field like {{issue.summary}} in a match's regular expression, the trick is to first create a variable with the expression, and then use that in the match:
Please adjust the expression / grouping as needed for your scenario.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One more thing, do you know if list.get(index) works when index is a smartvalue? I just can't make it work, I saved the index in a variable (myIndex) and logs the right number, but with get fails.
Tried get({{myIndex.asNumber}}) but that fails too:
Failed to get value for ParseTareas.split(",").get({{PosicionTareaActual.asNumber.plus(1): {{ ParseTareas.split(",").get({{PosicionTareaActual.asNumber.plus(1)}}) }}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
At this time, there are at least two versions of the get() function for automation rules: for lists and for lookup tables.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill SheboyThanks for clarifying.
I am under scenario 1.
With your help I was able to iterate the list to find a match for issue.summary, but I don't have a way to get the next item from the list.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am getting confused as to what is the source and the search criteria for your scenario, as you appear to be noting multiple different fields.
Would you please post images of:
Those will provide context and help us to have a shared understanding of what you are observing. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy the whole rule is too long, but here is the issue:
1) I create a variable and log its value (I get 1)
2) I use it to get the next item in the list.
Log SiguienteTarea and get nothing.
If you put get({{ProximoIndex}}) get an error. If you put get(1) you get the next element. Tried also ProximoIndex.asNumber with no luck.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The get() function for a list can only take a number for a parameter. It cannot take a smart value, either from a field or from a created variable.
If you review my earlier posts, I described how to perform this type of search using a match() function and a dynamic search expresssion.
When your rule is longer, you can try using either a screen capture or a browser addon which can scroll to grab the entire image.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was able to come up with the regex to capture the next item from the list after the match with issue.summary
Thanks a lot for your help with this post.
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.