I'd like to fetch the latest date between 2 custom fields in case they're exist, as followed:
CF1 exit after status "Active"
While, CF2 may or may not exist.
However, script is not working when the CFs is not exist.
I've written the followed script:
What are you intending to return?
return LatestDue = issue.getCustomFieldValue(cf2)
is saying return the date formatter set equal to a date value which will probably return null
If you want a date string
return LatestDue.format((Date) issue.getCustomFieldValue(cf2))
the value will need to be cast to a Date.
You may need to cast to Date for the after function although not so sure without testing that out.
You could also try just using "compare"
issue.getCustomFieldValue(cf2).compareTo(issue.getCustomFieldValue(cf1)) < 0)
DueField doesn't seem to be used here.
Hi @Tom Lister ,
Thank for the clarification.
However, I've not managed to do selective If's.
Meaning, it work good only when both fields exists.
But, in case, it may only CF1 exist.
Kindly,
Gilad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You code should always return values for cf1 and cf2 as long as the custom field definitions exist.
What won't always be present are the field values on each issue.
pull those out first
def cf1Value = issue.getCustomFieldValue(cf1)
def cf2Value = issue.getCustomFieldValue(cf2)
if(cf1Value != null && cf2Value != null && cf2Value.after(cf1Value)){
return LatestDue.format((Date) cf2Value)
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.
Great - could you mark the answer as accepted. Thx
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.