The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Structure Formula : find the max date of tickets in group by assignee tickets

Tehmina Aslam
Contributor
July 8, 2024

 

 

Hi,

I have structure where all the tickets are grouped by assignee: I want to check when the resource is free

  • I want to get the maximum date from the ticket assigned to the resource 
  • if the maximum date is not passed, then it shows that the resource is free by x days 

 

  • if the maximum date is passed yesterday, then it shows that the resource is free today

 

  • if the maximum date is passed already, then it shows that the resource is free since x days 
def jqlQuery = "due is not EMPTY"
Query query = jqlQueryParser.parseQuery(jqlQuery)
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())

// Find the maximum due date
def maxDueDate = results.results.collect { it.dueDate }.max()

def today = new Date()
def daysRemaining = maxDueDate ? (maxDueDate - today).days : null

// Return the desired message
if (daysRemaining == null) {
    return "Free"
} else if (daysRemaining >= 0) {
    return "Free in ${daysRemaining} days"
} else {
    return "Free"
}

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Tehmina Aslam
Contributor
July 8, 2024

I do it another way, 

 

IF dueDate < NOW():

  Round((NOW() - dueDate)/(1000 * 60 * 60 * 24)) CONCAT " days being free"

ELSE IF dueDate == NOW() + 1:

  "Free today"

ELSE

  Round(dueDate - NOW()/(1000 * 60 * 60 * 24)) CONCAT " days to be free"

If it is against the ticket it gives my the correct days since the resource is free or will be free but against Assignee its not giving me correct value .

 

Against Abdul Haseeb it should tell me 22 days to be free .. as his last day task due date is 30 July.

Screenshot 2024-07-08 174900.png

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events