I have an automation that sends the comments made to an issue to a Slack channel, replacing the user tag in Jira side with the appropriate user tag on Slack side (so people get notified).
What works so far:
On Jira, the mention appears as `[~accountid:7120...ff4600c98]`. I implemented a replace action (actually many of them in one rule) to change each account to Slack's corresponding string `<@U5D3UAZHC0J>`. To perform replace after replace, I save the comments filed to a variable {{message}}, and using "Create Variable" multiple times, I replace each entry and update {{message}} (as in the screenshot). The field "Smart Value" of these replacement is hard-coded for all.
Short answer: there is no synchronous processing, loop structure for automation rules at this time. And even if there was, smart value, list iterator scoping may prevent accessing the data you need to preform the search / replace operations.
Longer answer:
Context is important for automation rules. Would you please describe what problem are you trying to solve? That is, "why do this?" Knowing that and seeing your complete automation rule may reveal other solution approaches.
In the meantime, the method you described chaining replacements may reduce potential errors and improve rule performance. For example:
{{issue.comment.last.body.replace(firstAccountIdString, firstReplacement).replace(secondAccountIdString, secondReplacement).replace(thirdAccountIdString, thirdReplacement)}}
Kind regards,
Bill
Hi Bill, thanks for answering. I tried your suggestion and it worked for me - using .replace(...).replace(...).replace(...).replace(...) . Not ideal but gets the job done.
Answering your question, what I tried to solve is: send comments to Slack using the "Send web request" action, but showing real user names instead of the accountid code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Since you posted your original question, it appears the text function now converts account id values to the display name for users, eliminating the need for the chained replace() functions.
{{issue.comments.last.body.text}}
One side-effect is this will also remove other formatting in the comment body.
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.
Hi Bill, thanks for following up. In my case, I don't want just to display names, but to display a special tag. The same user has a accountid on atlassian, and an ID on Slack (messaging app). I want to replace the accound it with the Slack tag. But this is useful to know, 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.