Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Add multiple users to a Custom field when they are tagged in a comment in the Jira Automation

Seenivasan K December 17, 2024

 

How to Add multiple users to a Custom field when they are tagged in a comment in the Jira Automation.

2 answers

1 vote
David Freitez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2024

Hi @Seenivasan K ,

As @Aaron Pavez _ServiceRocket_ said, you need to extract the User from the comment and then add it to the custom field, so the rule is:

  • Trigger: Issue commented
  • Extract all the mentioned users in the comment and save in the on a SmartValue variable.
    • Build smart value with:
      {{issue.comments.last.body.match("\[(.*?)\]").remove("~accountid:")}}
  • Branching For Each SmartValue
    • Edit the Users custom field by adding the extracted user.

I am adding some screenshots of the testing of the rule on my test instance, in my case, I added the users to a field called Approvers:

Screenshot 2024-12-17 121757.pngScreenshot 2024-12-17 121829.pngScreenshot 2024-12-17 121854.png

 

Hopefully this helps you build your Automation rule.

Regards,
David

Seenivasan K December 17, 2024

Thanks for the reply @David Freitez 

Can you please elaborate branching and create variable in this automation, as I am facing Error.

Seenivasan K December 17, 2024

Screenshot 2024-12-18 113100.pngScreenshot 2024-12-18 113009.pngScreenshot 2024-12-18 112948.png

Seenivasan K December 17, 2024

Above attached screenshots are my automation, but it adds only one user in the customfield. I want to add multiple users dynamically. @David Freitez @Aaron Pavez _ServiceRocket_ 

1 vote
Aaron Pavez _ServiceRocket_
Community Champion
December 17, 2024

Hi @Seenivasan K 

To better understand this can you tell us;

- Is the custom field a user picker field?

- A text field?

- A picklist?

Regards

Aaron

Seenivasan K December 17, 2024

yeah its the  custom field a user picker field @Aaron Pavez _ServiceRocket_ 

Aaron Pavez _ServiceRocket_
Community Champion
December 17, 2024

Hi @Seenivasan K 

First, we can use this reply from @Bill Sheboy to extract the ID from the user mentioned in the comment

https://community.atlassian.com/t5/Automation-questions/Re-Re-Finding-Mentioning-a-User-in-Comment-and-Cust/qaq-p/2368567/comment-id/6895#M6895

Then you can add the value using this JSON body:

{
    "update": {
        "userpickerfieldhere": [{
                "add": {"accountId":"{{accountvariablehere}}"}
        }]
    }
}

Now if you want to append, you need to use:

{{fromString}} {{toString}}. More on that here:

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/ 

That should put you in the right track. Let us know how it goes!

Regards

Aaron 

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 18, 2024

Hi @Seenivasan K 

Adding to the suggestions from @Aaron Pavez _ServiceRocket_ 

In the linked post Aaron provided, that scenario was to Add Watchers, and so branching was appropriate.

But you are trying to select values in a multiple-select user field, correct?

If so, branching is a bad idea: advanced branching executes in parallel and asynchronously, processing in no particular order or timing.  This mean your rule's edits could repeatedly collide trying to edit the field.

Instead, once you have identified the users to add, find the current values, merge them with the new ones, and perform a single edit using JSON.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events