Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Calculate lifetime of a product

Hi,

 

I would like to calculate the lifetime of a product based on the difference between when the product has been released (custom field Launch date) and now.

I was trying to do it with the duration scripted field in scriptrunner but I have an issue : 

((System.currentTimeMillis() - customField[14311].getTime())/1000).toLong() 

 

Here is the error message :

 groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.fields.ImmutableCustomField.getAt() is applicable for argument types: (Integer) values: [14311] Possible solutions: getAt(java.lang.String), getId(), getName(), putAt(java.lang.String, java.lang.Object), wait(), grep() at Script101.run(Script101.groovy:1)

 

 

Can anyone help ?

Thank you 

2 answers

1 accepted

0 votes
Answer accepted

I figured it out, here is the final code :

((System.currentTimeMillis() - getCustomFieldValue('Launch Date').getTime())/1000).toLong()

Thanks for your time Ravi :)

 

Arthur 

0 votes

Hi @Arthur S 

There are few ways of doing it.

The snippet below has a method which I use a lot for date calculation.

def duration = TimeCategory.minus(
new Date(),
issue.created
)

However the script on the page match closely to your requirements.

Ravi 

Hi @Ravi Sagar _Sparxsys_ ,

 

What I am trying to do is to create a custom scripted field on "Duration" template.

When I do it this way :

((System.currentTimeMillis() - issue.created.getTime())/1000).toLong()

I have the following result :

48 weeks, 13 hours, 36 minutes 

 

But instead of comparing it to the created date, I would like to compare it to my custom field "Launch Date". 

For my understanding, this is giving me the field value : 

customField[14311]

but I am not sure how to convert it to the right type to compare it to System.currentTimeMillis()

 

Thanks,

Arthur

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13.2
TAGS
Community showcase
Published in Jira

Do you use Jira Cloud with Microsoft Teams?

Hi, Jira users! Do you use Jira alongside Microsoft Teams? We want to hear how you’ve used the power of Jira Cloud and Microsoft Teams (via the Jira Cloud for Microsoft Teams app) to achieve a team...

480 views 3 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you