When a new comment is created on an issue and one or more users are mentioned, I would like those users added to a multi user picker field. I can extract something that looks like an user id list but it only works when there is one user id. I think my issue has to do with improper formatting of the list so the smart value branch runs for each item. Any assistance would be greatly appreciated. Thanks.
Extracts ids from comment and adds a comma after each id
Removes last comma and splits extracted string ids to create a list
Smart value branch to run on each item in list
Adds the user id to the multi user picker field
Success log when only one user is mentioned.
Error log when two or more users are mentioned.
I had a similar issue. It kinda worked for me, when I put the ".split(",")" in the "Smart Values" field of the advanced branching.
Like this:
I guess this is because the advanced branching isnt treating the variable like a list and when you put the split there it will treat it like one.
But I still have a Problem with the multi picker. Because for me right now it always overwrite the multi picker instead of adding the user to the existing ones.
I hope this helps and maybe you can tell me, if you have the same problem with the overwriting.
Best regards
For the multiple-selection field symptom you describe, the fix is to not use branching (as that runs in parallel and will walk-over prior results).
Instead use a single issue edit with using JSON to add the values with advanced edit: https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Multi-select-custom-field
You may use list iterators on the values from your created variable to pre-build the JSON needed in the issue edit, and write that to the audit log to confirm the format is correct.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The match() function does not handle text with newlines, and other formatting, well for fields like Comments and Description.
One workaround to get better matches is to add a split(" ") immediately before the match() call, as that will reduce the scope the regular expression tries to search. For example, here is one I have used which also removes any duplicate mentions in the same comment, creating a CSV list of the account id values.
{{issue.comment.last.body.split(" ").match("\[~accountid:(.++)\]").distinct.join(",")}}
If you know you have many newlines you may also want to add this before the split:
replace("\n"," ")
Kind regards,
Bill
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 additional info. But before I start adding improvements I first need to solve for having the advanced branching iterate over smart value list of the Ids. As stated before, when there is only one id in the list it works but when you add another it doesn't. Let me know if there is any thing else I can share that would be helpful. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry for the delay in responding as I have been offline for a few weeks.
Did you try the expression I suggested? That will first split() on spaces to reduce the scope of the match() and produce a list of user account id values.
Then you will need to use an iterator of that list to create dynamic JSON to add the values in one edit action rather than with branching: https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Multi-user-picker-custom-field
Perhaps like this:
{
"update": {
"customfield_11768": [
{{#varListOfAccountIdValues.split(",")}}
{ "add": {"id":"{{.}}"} } {{^last}}, {{/}}
{{/}}
]
}
}
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.