Forums

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

use a custom script field, to set a number field

Connor Jakes May 18, 2018

Okay, so the real issue is that JIRA sees script fields as nothing more than a script field, regardless of what "type" of script field it is, so even though I already have a number script field that provides this value, it can't actually be used in filters because the only available filter is if its EMPTY or not.

 

SO I want to use the script in the scripted field, to also set the value of a number field. is this at all possible? Currently my workaround is to have a second script field that is empty if the number field and number script field are equal, and then a custom rule that looks for the second script field to be non empty, and if it is, then it updates the number field to equal the scripted number field. This is WAY more complicated than it needs to be. Is there a way I can just use the scripted field to set the number field?

 

def subtasks = 0
for (i in issue.getSubTaskObjects()){
if (i.getStatus().getName() != "Closed"){
subtasks += 1
}
}
if (subtasks == 0 )
if (issue.getStatus().getName() != "Done"){
subtasks = 1
}
return subtasks 

 it would be nice if I could just have a line like

issue.updateCustomField(16340, subtasks)

1 answer

1 accepted

1 vote
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 Leaders.
May 18, 2018

Ah, yes.  This is because scripted fields don't always know what you want for a searcher and template.

Go to the script definition phase and check that the "template" is set to "number"

Now go to the field in the list of custom fields (Admin -> Issues -> Custom fields), and edit it (not configure, it's the edit we need).  You will find it has no "searcher" set.  Select a numeric searcher and save it.

Re-index issues that the field is on, and you should find you can now search and sort on that field in the issue navigator.

Suggest an answer

Log in or Sign up to answer