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
Community Members
Community Events
Community Groups

How to put a condition on the date field before the issue created



Thanks for your excellent website.

I'm a Jira-service desk supporter.

I have got a project definition issue type and in this issue type, I've got a date picker field that has the Project Plan Delivery Date name. but I want to put a condition on this field for users can't pick a date for more than 2 months.

Also, I have "Adaptavist ScriptRunner for JIRA" but don't know how to write scripts.

I appreciate your help.


1 answer

1 accepted

0 votes
Answer accepted
import org.apache.xpath.operations.Minus
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil
import java.util.Date.*

// Get pointers to my date field and get its value as a date
def cf = getFieldByName("userdate")
def cfval = cf.getValue() as Date
if(cfval > 60) {
fieldScreen.print("Please enter a day less than 60 days")

I searched some things but don't know if this code is right or not. Can anyone help me, please?

You should edit your workflow, and on a specific transition, you can add a "Validator" that is called "Date Compare Validator"

Bez tytułu.png

Thank you @Marcin Wiktor 

I know this way but this is for when I created the issue.

I want something before the creation so as a result, I don't have workflow before the creation.

@CRS123456 but you can add this validator on a "create issue" path (literally the path that goes as first in your's workflow) - it will prevent people from createing an issue when this condition isn't match.

Like # people like this

@Marcin Wiktor 

You're right. I didn't know this so I learned a new thing.

It's working great, man. Thanks a lot. 


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Software

Upcoming changes to epic fields in company-managed projects

👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...

14,817 views 37 48
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