Jira Automation to update a user picker field with free text

Michael Savedra May 17, 2022

Hi!

Does anyone know how I would update a user picker field like Reporter using plain text from a plain-text custom field? 

I'm trying to pull the value from a free text field from related tickets and then change the reporter on the related tickets to the email value froim the custom plain text fields. Please see the attached photos for my setup.

The advanced edit (to update the reporter) looks like this:

{
  "update": {
   "Reporter" : [
        {
           "set": {
             "id":"{{triggerIssue.NGSD: User to transfer docs to (Free Text).accountID}}"
                           }
                            }
                              ]
                                 }
                                    }

 

The errors I'm receiving suggest to me the automation is reading the smart value as the plain text email and not liking it. Needless to say the automation test was unsuccessful.

When I tested this in my sandbox instance from a user picker field it worked so it must be due to the email being free text. 

Ultimately I just need to find a way to add the free text value (email address) to the reporter field. 

Any help on this would be majorly appriciated!

 

Thanks!

 

MikeScreenshot 2022-05-17 at 16.42.13.pngScreenshot 2022-05-17 at 16.42.32.png

1 answer

0 votes
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.
May 17, 2022

Hi @Michael Savedra 

If I am understanding your use case correctly, you cannot set a user field from just the email address in a text field.  Instead you will need to find the user's account ID and use that to set the Reporter.

If you are trying to do something else, would you please clarify the problem you are trying to solve?  Thanks!

Kind regards,
Bill

Michael Savedra May 18, 2022

Thanks for confirming that @Bill Sheboy

Do you know if it woudll be possible to find a user ID by searching the free text of the email within the jira automation?

Guessing it's not possible so I'll likely have to change the field to a user picker/find another solution..

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.
May 18, 2022

It is possible by calling the REST API using a web request to query for a user with that email address.  That approach will take a few seconds for the rule to run.  For example, which you can try in a browser to confirm it works for you:

yourJiraUrl/rest/api/2/user/search?query=emailAddressToFind

Here are some references to get you started:

Michael Savedra May 25, 2022

Thanks @Bill Sheboy I appriciate your help with this. 

Unfortunately it seems like I'd need to store an auth token in plain text in the automation which poses too much of a security risk, unless you know of a way to encrypt that?

 

Thanks,

 

Michael

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.
May 25, 2022

Several people have pointed out that potential security issue for rules.  There is one improvement that can help a bit: You can limit who can edit a rule and so that will limit easy visibility to the token.

rule save.PNG

There are also some open suggestions for better security of tokens/authentication:

https://codebarrel.atlassian.net/browse/AUT-1458
https://codebarrel.atlassian.net/browse/AUT-2117
https://jira.atlassian.com/browse/JRACLOUD-77817

Rabbit Stoddard October 14, 2022

It looks like https://codebarrel.atlassian.net/browse/AUT-2282 was implemented; headers can now be entered separately, and hidden.

 

Now the problem I'm having is that the api call for user search isn't working

 

or 
results in a 200 success, and an empty array/no matches found result, even when I use my own data to test. I'm wondering if this is a GDPR thing, but it's really frustrating when we need to set users based on plain text. 
Marc Isikoff December 6, 2022

Back to the OP.

We are still having problems in that we can retrieve a pure text field of either a person's ID or their name but putting text into a people picker field in Jira Service Desk gives us this error suggesting you cannot do this:

java.lang.ClassCastException: class java.lang.String cannot be cast to class com.atlassian.jira.user.ApplicationUser

 

I'm hopeful that if a text field in Jira can be populated, there might be a away to automate (e.g., Automation for Jira) a people picker field.

Suggest an answer

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

Atlassian Community Events