Update Custom Select Field by ScriptRunner

Alex Sander November 6, 2024

Hi. I'm trying to update some Custom Select Field in scriptRunner.

- I'm getting the value from issue1 with

issue1.getCustomFieldValue(customFieldId)

- I need to set this value in issue2 (same project, same issuetype)

- I'm using this:

issue2.update {
setCustomFieldValue(customFieldId, valueReadFromIssue1)
}

It works fine for most fields, but from "Select Field" field types the value is not updating.

No error messages.

Does somebody help me to solve this question?

 

 

 

 

2 answers

2 accepted

2 votes
Answer accepted
Bobby Bailey
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.
November 6, 2024

Hi @Alex Sander , 

 

@MattD 's script will help you solve your issue, I am just conscious that uses the old, Pure Java API method, rather than HAPI, which you report as not working. I just wanted to ask a few questions to see if we can get to the bottom of it to keep your script simple!

I built out the same code in essence and it worked:

def newValue = Issues.getByKey('WEB-5').getCustomFieldValue(10613)

log.debug(newValue)

Issues.getByKey('WEB-4').update {

    setCustomFieldValue('Custom Single Select', newValue)

}


If you could, could you log out the value of the field? Also, if you are willing, could you share the version of ScriptRunner you are on?

Kind regards, 

Bobby

Alex Sander November 6, 2024

Hi @Bobby Bailey 

I'm using scriptrunner ver v. 8.36.0.

I guess it's a bug, or some wrong with my test environment, user or something else.
A coworker is helping me and it works for him the same way you did.

thanks for helping.
regards

Bobby Bailey
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.
November 6, 2024

Oh interesting! I am glad you have got it working! 

If you run into that issue again and can reproduce it, please let us know so we can catch and fix it!


Like # people like this
Alex Sander November 6, 2024

Thank's @MattD
I'm going to check the solution.

Suggest an answer

Log in or Sign up to answer