The goal:
Take all mentions from the last comment, filter out the issue's current assignee if they are added and insert the users mentioned into a custom field.
The approach:
split the mentions from the comment into a custom variable and use that to insert into custom field
The problem:
I'm struggling to filter out the current assignee from the array
I've tried:
I know i can use advanced branching but as this is part of a bigger autmation, this isn't an option.
I've tried looping through array and filtering out the assignee but it doesn't work.
I've tried using different functions like .replace .remove but no luck with any of these.
I don't even know at this point if I'm approaching this in the right direction as I don't really work with smart values.
Can someone guide me in the right direction?
This is what is being used to create the custom variable:
{{issue.comments.last.body.replaceAll("\\n", "").split(" ").substringBetween("[~accountid:", "]")}}
For a question like this, context is important for the community to help. Please post the following:
Until we see those...
From what you describe, there are at least a couple of ways to do this:
I recommend using the first method as I have observed inconsistent results with automation rule support of regular expressions which do not contain a string.
Kind regards,
Bill
Thanks for the response @Bill Sheboy
This is on a company managed project but the automation will run across both company and team managed projects.
It is on the cloud version of JIRA.
Currently I have this which extracts the mentions and updates a custom field. the aim is now to insert all mentions excluding the assignee if they are included.
This is using a manual trigger for testing but is on a scheduled trigger when its live
I've tried iterating through it and printing out a comment so i can see if it works. This is what I've tried:
Split the mentions into a custom variable called mentionedUsers using:
{{issue.comments.last.body.replaceAll("\\n", "").split(" ").substringBetween("[~accountid:", "]")}}
Then print out a comment trying to loop over the variable and only print if is NOT the assignee using:
{{#mentionedUsers}}
{{#if(not(issue.assignee.accountId))}}
{{.}}
{{/}}
{{/}}
However, it just seems to be printing out everything including the assignee. I've printed out the custom variable and the assignee accountId to make sure they are the same and they seem to be so I'm a little stumped.
my understanding is that it should check if the current index is NOT the same as the assignee.accountId and the {{.}} should print out whatever is on the current index. Am I on the right track?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for that information, @Zaine Abaddin
First, your variable is text, and needs to be split() back into a list for iteration.
And...The symptom you are seeing is a long-standing limitation in the long-format of list iteration: Inside of a long-format iterator, only data from that scope, and lower is visible. Thus, the assignee cannot be "seen" inside to filter the variable when iterated.
One possible workaround for this scenario is to use inline iteration, as that allows access to external data:
{{issue.comment.last.body.replace("\n", " ").split(" ").match("\[~accountid:(.*)\]").distinct.replace(issue.assignee.accountId, "").match("^(.++)")}}
How that works is:
Some of those steps could be combined using replaceAll() with the regular expression, although I have seen that function be "glitchy" sometimes.
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.