You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.
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.