Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Restrict due date using simple script validator

I am trying to restrict the due date field by preventing users from setting the due date 24 hours from the date that they are attempting to create the ticket. I am using ScriptRunner to create a simple scripted validator. I have been successful in preventing ticket creation with the below script, but it prevents all tickets from being created (Im guessing it might have something to do with the sql import when im using postgres, but I couldnt find a postgres equivalent).

 

import java.sql.Timestamp
def duedate = issue.DueDate
def noticket = new Timestamp((new Date() +1).getTime())

duedate > noticket

1 answer

1 accepted

0 votes
Answer accepted
Payne Community Leader Feb 25, 2019

issue.DueDate is invalid. Though the compiler doesn't flag it, it gets logged as an error. Try issue.getDueDate() instead.

Note that though the field is of type datetime, the interface accepts only a date, so the system will set the time to 0:00:00, meaning that if the user selects a due date of tomorrow, it will always fail; it will not fail for a due date of 2 or more days out.

e.g. if I create a ticket now with a due date of tomorrow

now = 2019-02-25 14:35

noticket = 2019-02-26 14:35

duedate = 2019-02-26 00:00

duedate > noticket returns false

but if I create a ticket now with a due date of day after tomorrow

now = 2019-02-25 14:35

noticket = 2019-02-26 14:35

duedate = 2019-02-27 00:00

duedate > noticket returns true

This worked perfectly! Thank you!

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you