Forums

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

defect end date must be greater than defect start date

Garden16_ January 26, 2022

I have two date custom Fields :

Defect logged date and Defect closed Date .

I want defect closed date to be  greater than Defect logged Date .I would like to  give message if the close date entered by the user is before the logged date . How do I do this using Behaviors using script runner .

2 answers

1 vote
Garden16_ January 26, 2022

I tried this code . its not working 

one other thing I have made is I have disabled(grayed out ) the DetectedDateField field in the transition screen using behaviors. But I would imagine the Date value  will still be collected by the get feild Id getFieldById("customfield_11703")

 

 

import com.onresolve.jira.groovy.user.FieldBehaviours


def DetectedDateField = getFieldById("customfield_11703")
def DetectedDateValue = DetectedDateField.getValue() as Date
def ClosedDateField = getFieldById("customfield_11600")
def ClosedDateValue = ClosedDateField.getValue() as Date

DetectedDateField.clearError()
ClosedDateField.clearError()

if (ClosedDateValue != null && DetectedDateValue != null ){
if(ClosedDateValue>DetectedDateValue){
ClosedDateField.setError("Defect Closed Date must be greater than Defect Detected Date")
}
}

1 vote
Pramodh M
Community Champion
January 26, 2022

Hi @Garden16_ 

Here's the script, modify and add it to behaviour to check the date field entered 

https://community.atlassian.com/t5/Jira-questions/Need-help-with-a-script-to-compare-dates-in-Scriptrunner/qaq-p/901009

Thanks,

Pramodh

Garden16_ January 28, 2022

This is not working.

 

import com.onresolve.jira.groovy.user.FieldBehaviours


def DetectedDateField = getFieldById("customfield_11703")
def DetectedDateValue = DetectedDateField.getValue() as Date
def ClosedDateField = getFieldById("customfield_11600")
def ClosedDateValue = ClosedDateField.getValue() as Date

DetectedDateField.clearError()
ClosedDateField.clearError()

if (ClosedDateValue != null && DetectedDateValue != null ){
if(ClosedDateValue>DetectedDateValue){
ClosedDateField.setError("Defect Closed Date must be greater than Defect Detected Date")
}
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events