Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,251
Community Members
 
Community Events
165
Community Groups

In Jira Automation how can I set assignee to a "Firstname Lastname" value I get from another field?

I am using OpsGenie Cloud with Jira Cloud and have configured the OpsGenie integration to add a comment to the Jira issue when an OpsGenie user acts on an alert. The comment that is added to the Jira issue looks like:

[Opsgenie]: Firstname Lastname acknowledged alert: "Alert Title"

I would like to assign the Jira issue to the "Firstname Lastname" user who is mentioned in the comment. All of my OpsGenie users are valid Jira users.

I am able to use the smart field {{comment.body.match(": (\w+ \w+) ")}} to pull out the "Firstname Lastname" string from the comment. I tried using that smartvalue to set Assignee but it fails. It seems that I need an accountID to set Assignee. How can I look up the accountID for that "Firstname Lastname" string?

Thanks for any advice.

1 answer

1 accepted

1 vote
Answer accepted

Hi @Kyle 

There is an open suggestion to find users by name from within an automation rule: https://codebarrel.atlassian.net/browse/AUT-725

As a work-around (albeit a slower one) you could use a webrequest to call the REST API with a user search to get the account ID, and use that for assignment.  Here are some references if you want to try that approach:

Best regards,
Bill

Thanks for the pointers to those articles Bill. I'll try the REST API way.

Like Bill Sheboy likes this

@Bill Sheboy with some experimentation I totally got it working. I like it. Thanks again for the pointers to a solution.

 

For future reference here are the automation steps that I used:

1. a "Send web request" step configured as follows

- Webhook URL: https://<put-your-sitename-here>.atlassian.net/rest/api/3/user/search?query={{comment.body.match("\[Opsgenie\]:\s(\w+\s\w+)\s").urlEncode}}

that smart field match gets the "firstname lastname" from the comment and urlEncodes it to be part of the REST API query parameter, use your own regex in this place

- Headers: Authorization = Basic <my-API-key-encoded-per-that-other-article>

- HTTP method: GET

- Webhook body: Empty

- check Delay execution of subsequent rule actions to that the next step can use the returned value

2. an "Edit issue fields" step which sets Assignee to

{{webhookResponses.first.body.accountId}}

Like # people like this

@Kyle Thanks for the detailed solution, this solved a very troublesome task I had been stumped on for some time. For anyone who is in a similar situation, I was unable to execute the user lookup by email address from a python script remotely due to GDPR restrictions, but this webhook executed in the Automation panel apparently circumvents that block. 

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you