How to create a listener condition based on the value of a date custom field of the parent

Tomas Arguinzones Yahoo February 4, 2021

Hi,

I have a listener that I need to fire when the parent issue type is Bug and a date custom field on the parent is < Now(). Something like this:

 

issue.getParentObject().getIssueTypeObject().getName() == 'Bug' && issue.getParentObject().cfValues['GA Release Date']?.value < Now()

 

issue.getParentObject().getIssueTypeObject().getName() == 'Bug' works fine but  issue.getParentObject().cfValues['GA Release Date']?.value < Now() does not. I am not sure how to get the value of the date custom field of the parent and how to compare that value with Now()

 

Any assistance is greatly appreciated.

 

Thank you

 

1 answer

1 accepted

1 vote
Answer accepted
John Chin
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 Leaders.
February 4, 2021

Hi @Tomas Arguinzones Yahoo 

I assume the script is run on the Script Listeners and not in the Workflow condition?

If in the Script Listener, you can get the issue parent custom field value by using the following sample script:


def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Date")

def cfValue = issue.getParentObject().getCustomFieldValue(cf) as Date

log.warn "Custom Field value: "+cfValue

def now = new Date()

log.warn "Now: "+now

if(cfValue < now)
{
//dosomething
}

If doesn't help, please let us know where you run the script or send over some screenshots for us to have an overview.

Suggest an answer

Log in or Sign up to answer