Automation-populate a user picker field from email body

Benjamin Leidner
Contributor
February 28, 2023

Hello community-

I am so close to completing this automation but am hitting a wall on the final piece.

We get an email from our HR system that generates a Jira ticket.  We currently manually fill in the fields of the ticket based on the data in in this email.  But I don't want to do that anymore :)

I have successfully set up the rules to parse the body of the email and populate the appropriate fields.  This is the body of the email:

Name: Jonathan Doe
Company: Our Company, LLC.
Group: Information Technology
Start Date: 5/1/2023
Supervisor: Benjamin Franklin
Title: Vice President
Location: New York

I parsed every line to populate the relevant fields but I cannot figure out how to populate the Supervisor field.  It is a User Picker field (we synch our directory with Azure AD) and will also be the initial assignee of the ticket.  I know Jira uses their own Atlassian ID string to reference user accounts so...  Is this even possible?

Thanks!

-Ben

2 answers

1 accepted

0 votes
Answer accepted
Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 28, 2023

Hi @Benjamin Leidner,

Can you get their email address? It might be possible to use that to set the Supervisor?

Cheers,

Simeon. 

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 28, 2023

Simeon beat me to it! We always have an exterior app send the user’s email address. Then that works like a charm.

Benjamin Leidner
Contributor
March 1, 2023

Thanks both of you for your replies.  Alas, our HR system is woefully inadequate.  I'll ask if they can add an email address but it was like pulling teeth just getting them to send us an email in the first place.  If I import all the users into "Assets" can I do some sort of lookup to there?  Or...  This would only be about 95% accurate but can I use a regex to create an email from the email that HR provided?  Something like: Grab the last name (last word of that line) plus the first initial from the word before, concatenate, and append our domain (@company.com)? I know, it's kludgy, but it's all I've got to work with :(

Like John Funk likes this
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 1, 2023

I think you are only asking for trouble doing that. Either HR wants to be a part of the solution or not. I would escalate that upwards if they don't. There's no reason for that type of siloed behavior in my opinion. I would expend your energy on that versus trying to work around them. 

Benjamin Leidner
Contributor
March 2, 2023

I agree with you completely and just reached out to our HR department.  Here's hoping they will be amenable.

If they can add the supervisor email then it's straightforward to automatically send the ticket directly to the supervisor.  But how do I populate "Supervisor" in the ticket?  If I put the email address in the "Supervisor" field, will it automatically pick up the associated user account in my directory?  Or will I still need to do some sort of lookup?

Thanks again for your help on this.

-Ben

Benjamin Leidner
Contributor
March 13, 2023

Hi all.  Update:  HR has added the supervisor's email address to the notification.  Sooo...  what now?  I've tried translating the email to the Supervisor field, I've tried creating a variable, I've tried just slamming the email into the assignee but can't finalize this last piece.  Now the incoming email body looks like this:

Name: Jonathan Doe
Company: Our Company, LLC.
Group: Information Technology
Start Date: 5/1/2023
Supervisor: Benjamin Franklin
Supervisor Email: bfranklin@company.com
Title: Vice President
Location: New York

Best case, I need to populate the supervisor and assignee fields with the associated user but I'll take either or, or maybe even just an eamil-this-issue at this point.

Thanks again all,

-Ben

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 13, 2023

How have you tried setting the email as the field value?

Benjamin Leidner
Contributor
March 13, 2023

Trying to.  Some of the things I've tried---

I create a smart variable {{userName}} with the email address (which sits between the text "Email: " and "Title" in the email body...

{{description.match("Email: \s(Title*)")}}

And then I try to assign the issue to the variable...

Assign Issue-->Smart value--> {{userName}}

And populate the supervisor field with the variable. {{userName}}

And email the issue... to {{userName}}

But none of these work.

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 13, 2023

Have you logged out what you're storing the email address as to be certain it is correct?

Setting an email address for the user field should work on the Edit action.

Like John Funk likes this
Benjamin Leidner
Contributor
March 13, 2023

I have not and that’s(of course) a great idea. I’ll try that and report back.  I also noticed I can lookup a user using their email address this way so that leads me to believe the API can definitely do it. One way or this is happening:)

https://my company.atlassian.net/rest/api/3/user/search?query=user@company.com

 

thanks Simmo

Like John Funk likes this
Benjamin Leidner
Contributor
March 17, 2023

Circling back here.  With the help I received here, I got it to work. 

Once HR added the hiring manager email address to the notification email, I was able to parse that to create a {{username}} variable.  Then I do an API call to pull the associated user account:

https://company.atlassian.net/rest/api/2/user/search?query={{username.urlEncode}}

And it works.  The returned account is the hiring manager, which I add as assignee and the ticket goes directly to them.  Thanks everyone for your help, especially Simmo.

 

-Ben

Like # people like this
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 18, 2023

Great! Glad you got it working @Benjamin Leidner  Simeon is the man!

Like Simmo likes this
0 votes
Mark Mahacek
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!
April 11, 2023

I'm looking to do this too.  Can you share more details on your final solution?

Benjamin Leidner
Contributor
April 12, 2023

Hi Mark.  Sure.  It is all done through Automation (Projects / <project name> / Project settings / Automation):

 01-Automation step 01.jpg

02-Automation step 02.jpg

NOTE: In my case, The text of the Supervisor email is between “Email:” and “Title” as above but this depends on the text of the email you receive.  Here is a snippet of the email I receive from HR…

Supervisor Email: BFRANKLIN@mycompany.com

Title: Intern

 

ALSO NOTE: if the supervisor email address is a hyperlink, the automation may choke on the HTML so try to ensure the email is text format or the email address is not a hyperlink.

The next step in the automation is to query Jira cloud for the username of the supervisor, based on the smart variable “username” defined above.

03-Automation step 03.jpg

You will need to add a header named “Authorization” with the value of

Basic APIKEYABCDEFG!@#$%^&...

Info on creating an API key may be found here but the API key must be base64 encoded.  I use this website to do that.  Enter the email address you used to create the API key, a space, then the API key and click to Base64 Encode.  The result is what you add in the header above after the word Basic.

 04-Automation step 04.jpg

The final step in the automation is to Edit the issue fields you want with the API call result.  I populate the “New Hire Supervisor” and “Assignee” fields:

05-Automation step 05.jpg

 

And that's it.  Hope this helps.

-Ben

Mark Mahacek
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!
April 12, 2023

Yes.  Thanks!

Like John Funk likes this
Benjamin Leidner
Contributor
April 18, 2023

I'm reasonably new here too and still learning but happy to help.  Please click the above to accept my answer.  Thanks!

Benjamin Leidner
Contributor
April 18, 2023

Wait.  This was originally my question so Simmo deserves the credit and his answer is accepted as the right one.  Apologies, I'm still new here too :)

Like John Funk likes this
Norm Lee
Contributor
June 30, 2024

There have been changes since.  This is what worked for me.

  1. Web Request URL - https://<your company>.atlassian.net/rest/api/2/user/search?query={{username}}    (or whatever you named your variable)
  2. When encoding the API key to Base64 - Rather than a blank space, use a colon between your email address and the API token itself so it looks like this: <your-email>:<API-token>
  3. Editing the Issue field - {{webResponse.body.accountid}}
Like John Funk likes this

Suggest an answer

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

Atlassian Community Events