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,460,438
Community Members
 
Community Events
176
Community Groups

Using a date/time stamp in workflow transition condition

I'm using a scripted condition on a workflow transition which only allows the transition if:

  1. The FixVersion field is empty OR
  2. The current time/date > FixVersion Start Date + 9h


The script I am using is as follows:

import java.sql.Timestamp

def today = new Timestamp(new Date().time)
def branch


def fixVersions = issue.fixVersions
if(fixVersions){
if(fixVersions*.startDate == [null]){
return true
}

def branchDate = fixVersions[0].startDate
branchDate.setHours(branchDate.getHours() +9)
branch = new Timestamp(branchDate.time)
}


if (today > branch) {
return true
} else {
return false
}


Expected Result:
If the FixVersion Start Date is set to Jan 13, 2022, the condition should be TRUE after 9am on Jan 13, 2022. 

Actual Result:
If the FixVersion Start Date is set to Jan 13, 2022, the condition is TRUE after 9am on Jan 14, 2022

Any ideas what I may be doing wrong?

1 answer

0 votes

Have you tried using TimeCategory?

Try this:

import groovy.time.TimeCategory

def fixVersions = issue.fixVersions
if(!fixVersions) return true //there are no fixversions on the issue
if(fixVersions.every{!it.startDate}) return true //all fix version have no start dates

def branchDate = use(TimeCategory){
fixVersions[0].startDate + 9.hours
}
if(branchDate <= new Date()) return true //current date is after the branch date

return false //all other true conditions failed

The timecategory block will show an error in the code editor, but it should work.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events