Forums

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

How use scripted number field in jira filter?

Shah Baloch
Contributor
April 26, 2022

I have scripted the number field "Issue Age", which calculates the issue created date and the current date and displays the number of days. I would like to display the issue age in Jira Dashboard, I created three filters, one is to display issue age that has a number 15 or less, the second is 16 to 30 and the third one is 31 and more. 15 or less, and 30 or more seem to be working fine. But the middle one is not working. It is displaying issues for those more than 30 days old, like 35, 39, etc. It is supposed to not display more than 30. Any idea why it's not working and how can I fix it? Here are all three filters:

Less than 15: project = HR AND issuetype in (Bug, Story, Task) AND resolution = Unresolved AND "Issue Age" < "15" 


 16 to 30: project = HR AND issuetype in (Bug, Story, Task) AND resolution = Unresolved AND "Issue Age" >= "16" AND "Issue Age" <= "30"

31  and greater: project = HR AND issuetype in (Bug, Story, Task) AND resolution = Unresolved AND "Issue Age" >= "31"

First filter <15 only time works if I do not include equal (=) if include <= then it includes issues that have more than 15 days in age field. I'm not sure if the custom number field behaves differently than text fields?

Thank you for your help.

1 answer

Suggest an answer

Log in or Sign up to answer
2 votes
David Carrera del Castillo
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 13, 2020

Hi, I've found a solution to get the archived fix versions in the scriptrunner validators. Here is my code:

 

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.component.ComponentAccessor;

import com.opensymphony.workflow.InvalidInputException

IssueManager issueManager = ComponentAccessor.getIssueManager()
Issue myIssue = issueManager.getIssueObject(issue.getKey())

// myIssue -> the issue object in the past. 
// issue -> the issue object in validation time
// To avoid false positive when removing all the fixed versions, we are checking if any of these fixed versions of the issue in the past are archived. if (issue.getResolution().name == "Fixed or Completed" && ! (issue.fixVersions || myIssue.fixVersions*.archived.contains(true))) { throw new InvalidInputException("fixVersions", "Fix Version/s is required when specifying Resolution of 'Fixed'") }

 

As you can see, my solution is to instance another issue object with the same key. 

TAGS
AUG Leaders

Atlassian Community Events