Hello @Marat
It's possible but with plugins.
You can do it using Behaviour module of the Script runner plugin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can add field mapping for the due date field in the behaviour section and check everytime the user enters the value if the value of the date is "last date" or not. And if it's the last date then you can show the error message.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
See the behaviour API, they are fix of groovy and JS
https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
https://scriptrunner.adaptavist.com/latest/jira/behaviours-api-quickref.html
See the behaviour API, they are fix of groovy and JS
https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found the script, but it does not work. can you help ?
import groovy.time.TimeCategory
import java.util.Date
def DateField = getFieldByName("due date")
Date DateVal = (Date) DateField.getValue()
Date now = new Date()
if(underlyingIssue.getDueDate().before(now)){
DateField.setError("Error")
DateField.setFormValue(null)
}else{
DateField.clearError()
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share the screenshot of the configuration, also can you add some logging to your code
log.info " .....text here ..."
So that we know for sure that the code is being executed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For getting the due date object you can use the code
def dateField = getFieldById(getFieldChanged())
Also issue.getDueDate() return the object "class java.sql.Timestamp" and not "Date" as your code has date comparison, thus I would suggest you to add right type casting and may be in logs just print the value of the "due date" field before comparison and make sure both objects are of same type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Since Timestamp is a sub-class of Date thus you can assign the value to Date object.
https://docs.oracle.com/javase/8/docs/api/java/util/Date.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.