Our new Appfire Documentation Space is now live!

Take a look here! If you have any questions please email support@appfire.com

Set a date field to today's date - Groovy

Abstract

This code snippet sets a date field to today's date 

Logic

Pass today's date

Snippet 

new Date()


Examples

The output of this code snippet is a Timestamp which you could use in:

A Groovy expression, for example to:

  • Set a Date/Date-time picker field - Eg: Set the Due date to today's date in
    • one of the Set Field Value post-functions
    • the Create issue post-function under Set fields of new issue section

  • Conditionally execute a Post-function/Condition/Validator or Unlink issues  - Eg: Estimated delivery date is less than today

    issue.get("Estimated Delivery Date") <= new Date()

A Groovy template, for example to:

  • Notify the customer when the issue has been rejected as invalid through the
    • Comment in one of the Comment issue post-functions
    • Subject/HTML body/Text body of Email issue post-function

      Your issue has been rejected on <%=new Date().format("EEE, d MMM yyyy") %> since it is invalid
  • Write a JQL search expression in Link issues to the current issue post-function. Eg: Link issues which have been created since yesterday

    created > <%= (new Date() - 1).format("yyyy-MM-dd") %>

References