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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • 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

Disallow past date in date custom field

Hi All,

We have two date fields, i.e. "From" and "To". We want to implement following business logic on both fields:

1) Dates shouldn't be allowed in the past, better if we only allow date/time selection from now and any date/time in future

2) "To" date cannot be less than "From" date.

I have simulated an "Edit" transition that gives a workflow screen and I intend to use a workflow validator. We have Scriptrunner licensed. I referred to following pages, however I couldn't get a simple/custom script validator to work:

Anyone worked on similar solution and has a script that would work for the criteria above? 




1 answer

Hello @Anand Dandikar 

Please show us what you have tried that has not worked.

@Trudy Claspill thank you for looking into the issue.

After the field has been associated with the context and screen, past date are still being allowed on the "From" date/time picker field.

My script is as follows:

import org.apache.log4j.Category
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.pico.ComponentManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.opensymphony.workflow.InvalidInputException

// replace 10000 by number of date time custom field that must be validated
def fieldname = "customfield_16200"

ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
CustomField field = customFieldManager.getCustomFieldObject(fieldname)

Date value = issue.getCustomFieldValue(field)
Calendar now = Calendar.getInstance()
Calendar entered_date = Calendar.getInstance()
entered_date.setTime value

if (entered_date.get(Calendar.MONTH) == now.get(Calendar.MONTH) && entered_date.get(Calendar.YEAR) == now.get(Calendar.YEAR))

if (now.before(entered_date))

def invalidInputException = new InvalidInputException("Entered date is invalid! From date must be set in future")


It throws a warning with a yellow triangle as follows:

Variable "componentManager" masks a binding variable of the same name. Please choose a different name for variable "componentManager": @ Line 13, Column 18.

Application logs shows:

2021-03-18 09:44:54,066-0400 http-nio-8080-exec-17 ERROR Anand.Dandikar 584x21519x1 9hhrid,0:0:0:0:0:0:0:1 /secure/AjaxIssueEditAction!default.jspa [c.atlassian.velocity.DefaultVelocityManager] MethodInvocationException occurred getting message body from Velocity: java.lang.NullPointerException

When previewing the script with a test issuekey, I get:

groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.component.pico.ComponentManager.getCustomFieldManager() is applicable for argument types: () values: [] at

 JSU Automation Suite has data expression compare, however since we have already licensed Scriptrunner, we would prefer to implement this via a script validator. Please suggest.



Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Bitbucket Smart Commits vs. Genius Commits - What's the difference?

If you already heard about Smart Commits in Bitbucket, know that you just stumbled upon something even better (and smarter!): Genius Commits by Better DevOps Automation for Jira Data Center (+ Server...

106 views 0 2
Read article

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