The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Using Script field in another script

Marzi Goodarzian
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.
April 28, 2023

Hi

I wrote a script field previously, and now I want call this field in another script, but this field return null.

for example:

I wrote a field script that returm sum of a number fields in subtasks of a Issue(called Overall_Weight), and it returned correct answer and shown this answer in view screen.
Now ,I Called this field with by this method (issue.getCustomFieldValue(Overall_Weight) , but retuen null.

 I asked this question from Scriptrunner support , and tell me this problem fixed in jira 8.16  or above, my jira version is 8.5.0.

Did you use a solution in this version?
How to call script field in a another script?

Thanks

2 answers

2 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Nic Brough -Adaptavist-
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.
April 29, 2023

The short answer is that you don't.

Because of the way Jira works, you can not rely on the value of a scripted field being correct or even populated when you are running other scripts.

Your new script will need to replicate the code behind the scripted field.

Marzi Goodarzian
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.
May 2, 2023
0 votes
Answer accepted
Fabio Racobaldo _Catworkx_
Community Champion
April 29, 2023

Hi @Marzi Goodarzian ,

for my knowledge you can't reuse code in another context. The only way is to use the same code of your scripted field in your script.

Fabio

Marzi Goodarzian
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.
May 2, 2023