Scripted field showing blank value in JQL results

padraik
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.
August 3, 2022

I've created a scriptrunner scripted field that calculates a number value from the values in other fields on the issue.

The calculation is working correctly, and if I add the field to the view issue screen, I can see the value.

However, when I pull issues in a JQL query, the column for this field is blank and I can't figure out why.

My field type is: Scripted Field
My Template is: Number Field
My Searcher is: Number Searcher

 

4 answers

1 accepted

2 votes
Answer accepted
padraik
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.
August 3, 2022

I changed my return type to double, and it started working.

So, until I hear from an expert source or I find the docs myself, I'm going to assume that "Number Field" templated need to receive a Double =)

0 votes
padraik
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.
August 3, 2022

@Nic Brough -Adaptavist- - Is this normal with scriptrunner scripted fields?

0 votes
Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 3, 2022

Hi @padraik 

 

Does the value appear when you display the ticket then reload the search ?

I think the issue is computed when you load the ticket, if you don' t and do a search it will have no data.

 

Regards

padraik
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.
August 3, 2022

I wondered the same, but unfortunately that's not the fix -

 

To test, I opened this ticket first:

(all of the fields have values, but I erased all field values except for "Total Rank Score" before posting for privacy)
Annotation 2.png

Total Rank Score is a bunch of 9's for this issue, and is expected behavior from my script.

After this, I execute the search as pictured below, and the "Total Rank Score" column displays as empty for all issues:

Annotation 2022-05-10 143031.png

I have tried a re-index and the problem remains after.

0 votes
padraik
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.
August 3, 2022

I couldn't change the format in my original post.  Here is my script:

 

import java.lang.Float
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.issue.MutableIssue

def linkMgr = ComponentAccessor.issueLinkManager
def cfManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService.class)
def thisIssue = issue as MutableIssue

log.warn("setting total rank score for " + thisIssue.getIssueType().getName() + " " + thisIssue.getKey())

def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def iRankField = cfManager.getCustomFieldObjects(issue)?.find{it.name == "Initiative Rank"}
def iRankValue = issue.getCustomFieldValue(iRankField)

log.warn("initiative rank = " + iRankValue)

def eRankField = cfManager.getCustomFieldObjects(issue)?.find{it.name == "Epic Rank"}
def eRankValue = issue.getCustomFieldValue(eRankField)

log.warn("epic rank = " + eRankValue)

def fRankField = cfManager.getCustomFieldObjects(issue)?.find{it.name == "Feature Rank"}
def fRankValue = issue.getCustomFieldValue(fRankField)

log.warn("feature rank = " + fRankValue)

def totalRankScore = 9999999999
def iMultiplier = 100000
def eMultiplier = 10000
def fMultiplier = 1000

if(iRankValue && eRankValue && fRankValue)

{

    totalRankScore = ((int)iRankValue*iMultiplier) + ((int)eRankValue*eMultiplier) + ((int)fRankValue*fMultiplier) as Float

    log.warn("total rank score = " + totalRankScore)

}

else

{

    log.warn("missing a rank value\n" + "total rank score = " + totalRankScore)

}

return totalRankScore


 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events