The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Script for Date Time Picker

Gor Greyan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
March 18, 2025

Hi Dear Colleagues,

I need a script for behavior, that will not allow selecting past date when creating a ticket for the date-time picker field. I have a scriptrunner and want to do it with behavior. Or advise another solution.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
March 18, 2025

A server-side script attached to the date field works like this:

import com.onresolve.jira.groovy.user.FormField

FormField dateField = getFieldById(getFieldChanged())

Date value = (Date) dateField.getValue()
Date today = new Date()

if (value != null && value.before(today))
dateField.setError("Date must not be in the past")
else
dateField.clearError()

 

Gor Greyan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
March 18, 2025

Hi, Dear @Radek Dostál

Thanks for the provided script, it worked for the create screen, but from the Customer Portal it is not working, but I did mapping with the issue type.

Please advice.

Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
March 18, 2025

You need to add service management mapping to the behaviour to make it work on portals (software and service desk both need specific mapping in behaviours). Other than that I think the same thing should work, so just the mapping.

Gor Greyan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
March 18, 2025

Dear @Radek Dostál
It worked. Thanks a lot!

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
March 18, 2025

Hi @Gor Greyan

I have provided a similar solution in this Community Post.

In the Community Post link provided, the Behaviour will throw an error if the Completion Due date is before the Issue Submission date.

Please take a look and let me know if you need further help with the code.

Thank you and Kind regards,
Ram