Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Populate a user picker field from the description field

This workaround is meant to help JSM projects where it is necessary to pull someone mentioned in a text format from the description field into a user picker field, like the Reporter field.

At the moment, the lookup of a user picker field is by ID and not text. Therefore, the A4J will not be able to add the user account and the field will be "Anonymous".

Workaround steps:

  • Issue creation:

    Usually, anyone looking for this workaround is because they are using an automatic ticket creation method, for example, when a ticket is automatically created from a Slack channel, so you will need to have a default value in the Description field so that A4J can get the username, see below:

    "Please activate the offboarding process and ensure the account is terminated on the limited date. The owner of this account is xxxxxx."
    The automation rule will get the values that are after the "is" until the "dot".

     

  • Automation rule:
    • It will be necessary to create a variable, "username" for example with this smart value: {{description.match("The owner of this account is\s(.*)")}}Screen Shot 2022-09-14 at 16.51.27.png
    • It will be needed to create an API token for the Web Request process. The Web Request needs your credentials and an API token encoded with base64:Screen Shot 2022-09-14 at 16.55.52.png
       Note: the Get function of the Web Request to get a user account has some limitations. It will take the first option that appears in the search, so if you have two similar usernames, the last name must be entered.

      For more information about this procedure, please refer to the documentation below:

    • Add an edit action into the desired user picker field with this smart value: {{webResponse.body.first.accountid}}Screen Shot 2022-09-14 at 17.03.11.png
    •  Extra tip: if you want to mention the user in a comment, use the smart value: [~accountid:{{webResponse.body.first.accountid}}]Screen Shot 2022-09-14 at 17.11.11.png
  • For more information on how to configure these steps, please refer to the video below:

27 comments

Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 14, 2022

Awesome!

Like Bruno Altenhofen likes this
Elspeth Kelly October 11, 2022

This is an amazing workaround!
Thanks for sharing this @Bruno Altenhofen 

Like # people like this
Gabriele Cecco
Contributor
May 20, 2023

Very useful! Thanks @Bruno Altenhofen 

Janusz Bułakowski August 25, 2023

cheers for magicthegathering in the webhook address :)

siviani_madrigal September 11, 2023

@Bruno Altenhofen  

I have similar case but something is wrong and it is not working this workaround on my side.

I got a custom field Text format, user will fill it with email address or user name, based on that value the assignee field needs to be change every time the custom field is updated.

The web response is not retrieving any results, not sure what is wrong. Will appreciate your support!

krunoslav.majer October 19, 2023

Similiar issue as @siviani_madrigal 
I am pretty close to your automatino but a bit simpler. 

My issue is that I tried to get the username and when testing it in a rest client it works but the automation rule (although returning 200) has no body.

Any idea?

siviani_madrigal October 23, 2023

@krunoslav.majer I was able to resolve my issue, the problem I was having is in the API token encoded with base64. When I tried to encoded my API token with my email, I was leaving a space between email and API, and for that reason the space was creating a character and cause trouble in the authorization. 

Like krunoslav.majer likes this
krunoslav.majer November 14, 2023

@siviani_madrigal 

I also got it working after tickering around with the request. Can't even tell you what exactly the issue was 🤷‍♀️

Darren Boyle April 11, 2024

Thank you. We used this method to populate multiple users into the Approvers field from an Employee Object's custom field. This along with the For Each Branch made it possible. Thanks again.

Nico Harold
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 18, 2024

Figured it out!  I was misunderstanding the authorization part.

 

I cannot get this to work and have tried numerous variations.  I can tell I am getting a successful response as I have validated on an issue but I cannot seem to get anything back.  I do not understand why Jira does not update issue collectors to reconcile the email address provided against a JSM customer account to set the reporter.  The fact we have to use such a hacky workaround (that isn't even working for me) is ridiculous.  I've spent hours trying so many alternatives.

Has something changed where you can no longer search users with a name because of GDPR?  I've tried searching by the name, email address, etc...  I cannot get the webresponse back to a text field or a reporter when trying to get back the accountid.

Frédéric Thibert May 2, 2024

Hi,

Thank you very much for all your help in this topic, but I still don't understand the "Authorization" part.

 

You show to put "Basic" in your screenshot, but my webResponse.body is still empty, (the status is 200)

What is wrong ?

Sean Cooper June 27, 2024

@Frédéric Thibert if you can share what you're seeing perhaps someone can help.

siviani_madrigal June 27, 2024

Frederic, you need to encoded first your API token https://community.atlassian.com/t5/user/viewprofilepage/user-id/4238424

Important when you are in the enocoded64 app, suggested in the link above, when you add your email and the API token make sure to not left blank spaces, I mean your email has to be first and then the API token without any space.

this is supposed the format you have to enter the info in the encoded 64 you can try with using the same format as below usin the ":" after the email or you can just try having all together. 

<EMAIL>:<API_TOKEN>

 

In the Headers spaces, you will fill the first space with Authorization and then the second space you need to add: Basic <your API token encoded64>

Please be aware that after the word Basic you need to left a blank space

Hope this helps!! 

 

 

Kristóf Lauber July 22, 2024

Hi,

 

For me the web request always returns the account which is the first in the directory not the match, I attached the relevant part can someone take a look at it?

 

automation.png

 

Thanks in advance!

Sean Cooper July 22, 2024

Try this instead: {{webhookResponse.body.key}} though, I'm using Datacenter, so YMMV.

What does your audit log show?

Kristóf Lauber July 22, 2024

That will make the reporter field anonymous, I investigated further, the issue is with the "username" variable, somewhy it doesn't understand it

Sean Cooper July 22, 2024

What are you using to set the {{username}} variable? Write it to the audit log immediately after creating it.
What do your log entries show it's returning? Mine works a treat set as above.

Kristóf Lauber July 22, 2024

I use the same as here: {{description.match("The owner of this account is\s(.*)")}}

The log only returns "Log"

Sean Cooper July 22, 2024

That's an issue to begin with, definitely start there, searching for username = log  won't get your issue sorted. If you can share more info, perhaps share an example of your description field to help understand what you're trying to grab.

Kristóf Lauber July 22, 2024

I'm trying the same but with different text before the user's name, also tried it with the exact same setup as here, and also without anything other than the name, but all of them returned the same outcome.

 

I attached the requested info:desc.pngvariable.png

Sean Cooper July 22, 2024

What do you get when you write the previous assignee to the audit log?

Maybe it's better to ask what are you trying to do. Start from the very fist value you need and troubleshoot it until it returns an expected result and then move on. If your very fist variable has nothing useful then you'll forever be chasing your tail trying to troubleshoot further on.

You can get at the Previous assignee like: Solved: Jira Automation - Assign an Issue to Previous Assi... (atlassian.com)

Kristóf Lauber July 22, 2024

The issue here, is that this is for Assets, where this isn't possible in cloud

Mario Coluzzi
Contributor
July 29, 2024

Adding a Token in plain sight is an extremely dangerous solution. Any JSM user with access to the back-end has the ability to se it and utilize it . . . and the logs would point to the SysAdmin. Nope!

There might be an alternative approach to accomplish this task.

Sean Cooper July 29, 2024

Of course you'd keep the token in a secret key...

2024-07-29_13-50-09.png

Mario Coluzzi
Contributor
July 29, 2024

@Sean Cooper I believe you have posted setup for WebRequest Server not Cloud.

 

Can you please confirm?

 

 

Like Sean Cooper likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events