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,555,884
Community Members
 
Community Events
184
Community Groups

How to compare dates if createddate is specific day (groovy)

Edited

Hello,

I' I'm looking for a script to validate dates in my create transition. The usecase is:

if today is friday then the target date must be at least the next tuesday.

any ideas?

thanks in advance :)

1 answer

1 accepted

0 votes
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 30, 2021

Sure... simple enough...

User a simple scripted validator with this script:

def today = new Date()
today.day != 5 || cfValues['Target Date'] > today.clearTime() + 4

This will be true if either:

  • today is not a Friday
  • the target date is later than 00:00am on the 4th day after today

When the validator is true, the transition is allowed.

When the validator is false (both conditions above are false at the same time), then you specify the error message to display on the Target Date field

2021-04-30 10_29_19-Add Workflow Function Parameters.png

Hey Peter,

I tried your script but it doesn't work for me. I think I need to be more specific and my usecase changed a bit...

 

Target date must be apart 2 days from created date (example: created date = monday than target date can't be either the same day nor the next day). Additionally, if created date is a friday target date must at least the next tuesday.

 

thanks in advance :)

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 03, 2021

Then my guess is that if Created Date is a Thursday then the target date must be the next Monday?

If so, that's how I would do it:

def today = new Date()
def minDate = today.clearTime() +2
if(today.day in [4,5,6]){
//on thursday, friday or saturday add 2 days to account for the weekend
minDate = minDate+2
}
cfValues['Target Date'] > minDate

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events