You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi,
I'm traying to split a string and then iterate over the resulting array members.
The string is:
The split action is:
The result is:
The iteration attempt:
And finally the current value inside the loop is:
What am I doing wrong?
Thank you.
Hi @Inna S
In your images, you are showing multiple different variable names for the smart value expressions, and they do not seem to match.
For example, the Advanced Branch is showing {{TargetVersionsList}} and you do not show what that contains. Normally the branch is where the split occurs on an object or string.
Would you please post an image of your complete rule and audit log details? Those may provide more context for what you are describing. Thanks!
Kind regards,
Bill
Oh, sorry, I renamed the var and it is now TargetVersionsList, the result is the same:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Without seeing your complete rule, I suspect another problem is there is no split of the variable before it is used in the advanced branch.
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.
When you are trying to post an image of a longer rule, I suggest selecting the trigger in the rule editor, and then using a scrolling page capture tool. That will show the entire rule in one image.
Would you please post an image of the advanced branch? Again, I suspect the problem is the source smart value is not split, and so the branch tries to process it as one thing (not several).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'll try to do this.
This split trouble is what brought me here:
the field that gets read correctly is a string, as shown in the 'found on card' log entry.
And then the split is supposed to happen, as shown above.
And this split just 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.
Can you show me just your advanced branch setup and the smart value (or created variable) that feeds that? With those we can probably get the branch working fairly quickly, as the split may just be in the wrong place.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I've replaced the coma (",") with an underscore ("_") in the string, and found that the resulting var is in fact the list.
But I can't seem to access an individual member of the new list.
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.
When you have a list, you can access a specific item by: first, last, an index with get(index), or by match() with a regular expression.
If you instead need all of them, try the split() to feed the advanced branch.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's funny, when I add ".last" to the split statement, it brings the second part ok.
So the split works, but the loop does not bring 'every item' 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.
Okay...that is curious. If you can find a way to post the entire rule and audit log details images, that may help explain it.
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.
I'll have to call it a night, will be glad to hear if you or anyone would have an idea.
Thanks a lot, @Bill Sheboy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the images of your rule, and the action setups for the variables.
Based on what you show, the audit log does show each value is getting processed. If the advanced branch still matches your earlier images, this seems correct.
What is not working as you expected?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The 'current' entry is expected to be set to each of the, 3 in this case, parts of the string. This log action should appear 3 times in the audit log and not once. Otherwise how can I take action on them one by one?
Say, I need to clone the issue for several releases.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I understand what you are saying: you expected to see this three times:
"current myEntry is ..."
For some design reason, the implementation of branches is "smart" in that it collapses these down in the audit log because the prefix is the same, even though the loop does process three times. I personally consider this as a defect...regardless...
You can confirm this is indeed processing for each by doing something the rule cannot, either your desired action (i.e., clone the issue) or to write a comment with the same text to the issue.
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.
Please post an image of the advanced branch action for myEntry. Thanks!
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.
That appears to be the cause: a created variable is text, not an object or list. Please try splitting the variable in the advanced branch source with:
{{myList.split(",")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is much better, basically resolves my specific problem. Thanks a lot!
But I still do not see why the original split replaces the "_" with "," in a string instead of creating an array?!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am glad to learn that worked!
Regarding your question about the first split on underscores...
The first split on underscore created a list (not an array), and when that was then put into the created variable, it was automagically joined back into a text string separated by commas. Effectively it did this:
"12.13.14.15_87.98.65.12_44.5.78".split("_").join(",")
If you had seen values with square brackets, that would be an array...but you could not use the list functions on that value. It would require more functions to convert to a list.
Someday in the future, I hope Created Variables will be capable of storing objects (like the new Lookup Tables feature), and so the double conversion you did would not be needed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How is this an acceptable behavior?
Somewhere in this journey I had items inside square brackets, but I could not see why would the split function create anything but an array to iterate over.
More than that,
original string is coming from a lookup result: I search for an issue with lookup, then pick the single field of type "short string". And then invoke a split on it. This does not work.
Not in a 'create variable' step and not in the advanced branching.
But when this lookup.field result is assigned to a variable, this intermediate variable then can be used in the advanced branching to get an array.
What a mess.
Thank you so very much for your patience and help, @Bill Sheboy
You saved me the use of external tool for this particular task!
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.