Hi,
My goal is to add as watcher the first person tagged in a comment (no iterative branch in this case). I'm in a data center instance.
I followed the recommendation from Bill in this topic :
I have done a test by creating a comment with my coworker tagged "Test Automation @mycoworker" and checked in the audit log : the @mycoworker is not recognized.
It looks like the smart value is not working for me:
{{issue.comments.last.body.split(" ").match("(accountid:.*)]").remove("accountid:")}}
Any help on this please?
Thanks,
Regards
Hi @Garn
First thing, I am using Jira Cloud and not Data Center, and so please test the solutions I offer with your site.
The other question you linked to uses a solution approach for Jira Cloud, which includes a user's account id to implement a mention. However, I believe Jira Server and Data Center use a different mechanism with the user name.
Let's confirm that with your test rule: add a write to the audit log with this:
last comment body: {{issue.comments.last.body}}
Test your rule and review the log. I suspect the entry looks like this:
last comment body: here is my comment mentioning [~billsheboy] in the sentence
If that is the case, you may adjust the match() and remove() function parameters accordingly.
Kind regards,
Bill
Hi Bill,
Thank you for your help!
It displays:
last comment body: Test Watcher [~201034280]
With 201034280 being the identifier of the user.
Could you please share what it looks like in cloud so I can understand how to adjust match and remove functions please?
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for testing that!
For Jira Cloud, the mentions work like this, where 12345abcde would be the user's Atlassian account identifier:
[~accountid:12345abcde]
And so a change for your version to get the user identifier could be this:
{{issue.comments.last.body.split(" ").match("(\[~.*\])").substringBetween("[~","]")}}
Please test this for your instance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, thanks, we're almost there!
Now I have an error on the manage watchers action:
In my action, I'm adding as watcher my variable {{addwatchers}}
Do you have any clue on the error right here?
Thank you,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do not recognize that error message. Let's check on some things to narrow down that symptom...
First, check if the user mentioned can be added manually to the issue as a watcher, and then remove them.
Next, modify your write to the audit log for the variable to this and retest. This will identify if there are any stray characters leading / following the user identifier. If there are, they may be removed with the trim() function added to the end.
addwatchers: ZZ{{addwatchers}}ZZ
Finally, let's try to set the watch using the user display name. This will confirm if the watcher cannot be set with the user identifier in a rule action.
To try this, copy the Create Variable action and in the second one, later in the rule, set the value to the exact display name for the user.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill,
I confirm that I can manually add the user on the ticket.
I have updated the audit log with : addwatchers: ZZ{{addwatchers}}ZZ
The updated audit log displays :
Log action
I have created two variables:
watcher : ~201034280
watchertwo : 201034280
watcher three : FirstName LastName(201034280)
And the audit log:
watcher : {{watcher}} -- {{watchertwo}} ----- {{watcherthree}}
Please find the results with the same error:
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.
Hi @Garn
Sorry for the delay in responding as I have been offline for a few weeks.
Thanks for confirming what the variable contains, as the one with just the id should work in the action. (Unless those ids in Jira Data Center are numbers...in which case conversion is needed with asNumber.)
Would you please post an image of your current, complete rule and an image of the action where you Create Variable and where you use that with Manage Watchers?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, let me give you here the different codes for variables and the audit log to ease the understanding:
Variables:
addwatchers : {{issue.comments.last.body.split(" ").match("(\[~.*\])").substringBetween("[~","]")}}
asNumber : {{issue.comments.last.body.split(" ").match("(\[~.*\])").substringBetween("[~","]").asNumber}}
audit log2: add watchers: {{addwatchers}} ------- addwatchers with zz: ZZ{{addwatchers}}ZZ ---------- asNumber: {{asNumber}}
watcher : ~201034280
watchertwo : 201034280
watcherthree : Thomas AXXXXXXXXXX(201034280)
audit log3: watcher : {{watcher}} -- {{watchertwo}} ----- {{watcherthree}}
---- and now the audit log:
Looks like my asNumber is not working in the log action 2.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
asNumber is a function and so I advise not using that as a variable name to avoid confusing the rule.
Next, you are trying to add multiple things at one time as watchers and so that could be causing challenges seeing what works, or does not. Let's simplify to one single test and evaluate what happens:
{{issue.comments.last.body.split(" ").match("(\[~.*\])").substringBetween("[~","]").join(",")}}
varMentionedUsers contains: {{varMentionedUsers}}
{{varMentionedUsers.split(",")}}
Please note I explicitly added the join() and split() to avoid problems with the list being interpreted incorrectly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the add watchers, please try using this instead:
{{varMentionedUsers.split(",").asNumber}}
That will confirm if a number is required (rather than text from the variable).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am unclear why this is not working for your rule with a text (or a number) value for the watcher id. And I am certain setting the watcher from a variable works for Cloud and for other posts I have seen for Data Center.
I recommend working with your Jira Site Admin to submit a ticket to the Atlassian Support team. Perhaps they will see something we are missing. https://support.atlassian.com/contact/#/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.