Forums

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

Set value of a Single User Picker based on value of a Single Select List

Michael Thompson
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 Champions.
July 15, 2019

Hi folks,

I have a tough issue here and need some assistance coming up with a solution. 

Background

Jira Software 8.2.0
Adaptavist ScriptRunner 5.5.8.1-jira8

I have an inherited Jira Software instance that I have been slowly working on cleaning up, as it outgrew its original purpose long ago.

One of my projects has a Single Select List custom field named TTS Approver. It contains a text list users that can approve issues in the TTS project. I'm trying to get rid of this Single Select List in favor of a new Single User Picker custom field, which will be much easier to manage. Let's call it newApprover for now.

Creating the newApprover field is easy enough, and I've added it to the relevant screens in my test environment. The problem I face now is replacing the old TTS Approver information in existing issues (both resolved and unresolved) with this new field. I will then remove the old field from the screens and rename newApprover as TTS Approver. I'm looking at about 35,000 issues in this project alone.

Problem

I thought I could use ScriptRunner's built-in script Copy custom field values to simply copy the value from TTS Approver to newApprover, but this does not work with User Picker custom fields.

Does anyone know a way to script this such that the text value in TTS Approver = the name property of the newApprover user field, and thus the correct user will be populated in the field?

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Hana Kučerová
Community Champion
August 21, 2020

Hi @James Breunig ,

The script is attached to the Downtime Start field, which means, that it is executed, after the Downtime Start field is filled in. When you create the issue, you probably first fill in the Downtime Start field, then the validator is executed, but the Downtime End field is empty, so nothing happens, and then you fill in the Downtine End field, but there is no validator set.

Could it be the possible explanation?

So maybe you could add the second validator to the Downtime End field, because you want to do the check every time one of the fields is changed?

I also believe it is not neccessary to have all the imports in the script. It should work without them.

James Breunig
Contributor
August 21, 2020

Hi @Hana Kučerová

I've copied the script above into a server-side script for Downtime End. I've tried changing the order I fill them in. Still appears not to work.

Hana Kučerová
Community Champion
August 21, 2020

That's strange, it works for me :-(

Just quick check - did you setup mapping for the behaviour?

James Breunig
Contributor
August 21, 2020

Wow! That was it! I didn't know you have to pick a specific issuetype or it would not work. Thank you!

TAGS
AUG Leaders

Atlassian Community Events