Adaptavist ScriptRunner Jira DC - Behaviours (Date Picker Field B > Date Picker Field A)

Created by Sean Chua _Adaptavist_
* All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner 
 * license shall be granted a  non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed
 * or amended and must be included in any circumstances where the code snippet is shared by You or a third party." 

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor

@BaseScript FieldBehaviours fieldBehaviours

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def targetStartDateField = customFieldManager.getCustomFieldObject( Input CustomfieldID )
def targetEndDateField = customFieldManager.getCustomFieldObject( Input CustomfieldID )

def targetStartDate = getFieldById("customfield_XXXX")
def targetEndDate = getFieldById("customfield_XXXX")

def startDate = targetStartDate.getValue() as Date
def endDate = targetEndDate.getValue() as Date

if (startDate && endDate && endDate.before(startDate)) {
    targetEndDate.setError("Target End must be in the future of Target Start.")
} else {

Comments (1)

  1. Linda Melson


You can clone a snippet to your computer for local editing. Learn more.