Forums

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

How do I retrieve a script field value in a ScriptRunner listener?

cta-smiles
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!
August 26, 2019

 

I am trying to retrieve the value of a scripted field from a linked issue in a listener to be run when an issue is updated. I only need to read it, use it in a calculation and then update another field so I shouldn't be at risk of getting stuck in an infinite loop or something.

Here is the section that seems to be causing me problems.

def scriptField = customFieldManager.getCustomFieldObjectByName("scriptFieldName")

def scriptFieldValue = linkedIssue.getCustomFieldValue(scriptField)

 I can confirm that this works if I replace the name of the field with the name of a normal custom text field but as soon as I change it to a scripted field it won't retrieve the field value.

I assume this means that there is either another way to retrieve scripted fields in listeners or I'm trying to do something that can't be done.

Any help you can give me would be great. 

 

1 answer

1 accepted

0 votes
Answer accepted
Tarun Sapra
Community Champion
August 26, 2019

Hello @cta-smiles 

Please see this answer as to how you can get the value of the scripted field for an issue.

https://community.atlassian.com/t5/Marketplace-Apps-Integrations/How-can-I-retrieve-a-Script-Field-value-in-a-Scriptrunner-quot/qaq-p/798094

cta-smiles
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!
August 26, 2019

 

Thanks so much, this really helped.

Suggest an answer

Log in or Sign up to answer