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
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 =)
@Nic Brough -Adaptavist- - Is this normal with scriptrunner scripted fields?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
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:
I have tried a re-index and the problem remains after.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.
Learn more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.