Forums

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

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

Kyle
Contributor
August 3, 2021

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
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.
August 3, 2021

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

Kyle
Contributor
August 3, 2021

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

Like Bill Sheboy likes this
Kyle
Contributor
August 3, 2021

@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
Adrian Danemayer
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 2, 2022

@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