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 have the following scripted field. It is returning a value but it isn't the correct value. See code below and example.
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import java.util.Date.*
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def dateFieldObject= customFieldManager.getCustomFieldObjectByName('Restored Date/Time');
def dateFieldObject2= customFieldManager.getCustomFieldObjectByName('Incident Start Date/Time');
if(issue.getCustomFieldValue(dateFieldObject) && issue.getCustomFieldValue(dateFieldObject2))
{
def dateValue= issue.getCustomFieldValue(dateFieldObject) as Date
def dateValue2= issue.getCustomFieldValue(dateFieldObject2) as Date
return dateValue.getTime() - dateValue2.getTime()
}
EXAMPLE FROM TOOL: ((note MTRS is my scripted field))
Incident Start Date/Time: 2019-01-25 1:51
Restored Date/Time: 2019-01-25 04:52
MTRS: 17 weeks, 6 days, 16 hours, 40 minutes
The correct duration is 3 hours, 1 minute
Can anyone help me with this please ????
Hello @Brooke Anglin
Possible duplicate
You can add some logging and then see the unit of time returned and then you can convert it to the unit you want and return it as "double"
Have a look at the raw number that your subtraction gives you - your scripted field is converting it to text based on the wrong unit of measure.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the raw number also doesn't make any sense either. Another example is the duration is 20 min but the number template displays 1,200,000 and the duration template displays 1 week, 6 days, 21 hours, 20 minutes
How can the unit measure be corrected?
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.
WHY DID I NOT THINK OF THAT ?????? I was able to divide by 1000 and it gave me the correct duration
THANK YOU THANK YOU THANK YOU
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.
Welcome to the Atlassian Community!
All you need to do is convert the milliseconds result on the last "return" lline into seconds (dive by 1,000) or minutes (divide by 60,000)
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.