Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,091
Community Members
 
Community Events
176
Community Groups

Scripted field showing blank value in JQL results

padraik Rising Star Aug 03, 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 Aug 03, 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 Aug 03, 2022

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

0 votes
Florian Bonniec Community Leader Aug 03, 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

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.

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

Atlassian Community Events