Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Scripted field error Edited

I have created a numeric scripted field to obtain the difference in minutes from the update field and today date.

the code that I used is the following:


import org.joda.time.DateTime
import groovy.time.*

Date updatedate
Date todaydate
updatedate = new DateTime(issue.updated).toDate()
todaydate = new DateTime().toDate();

def milsec = todaydate.getTime() - updatedate.getTime() as double
milsec = milsec / 60000
return milsec.round()


the searcher is numeric. and the template is custom.

$numberTool.format('integer',$value)

 

in the preview mode  I'm getting the correct value, but qhen I check it in the issue navigator I'm viewing random and incorrect values when I refresh the browser.

ANyone have an experiencie doing this type of customization?
thanks in advance.

2 answers

1 vote

If you tried to reindex in your script, you'd throw the system into a recursive loop - it would try to reindex itself during a reindex during a reindex during a reindex...

I'm afraid your field idea is not going to work.  As Stephen says, the value of a scripted field is calculated and stored.  Your field is effectively a live clock - to get the right answer from it, you're going to need to calculate the value every second, for every issue.  That's simply never going to work.

The only sane way to do this would be to implement something in javascript, so the client browser does the calculation when necessary.  But it wouldn't be a real field, it would not be searchable.

What are you trying to achieve by calculating this?

Hi the idea is sent notifications after two days of inactivity in the issues.  So I want to to count the inactivity days ignoring the weekends.

in the code example I trying to do it counting minutes to test the notifications.

then using escalation service I move the issue to an autotransition when a JQL query is true. Using a postfunction to send the notifications

thanks.

Hi Sergio,

When you say the values are random / incorrect, do you mean that they are behind what you would expect to see?

Script field values are calculated and stored in the index at the time that the issue is indexed, e.g. when it is modified or transitioned, or when you do a full re-index. This would explain why you are seeing different values in issue navigator because those results come from a search (I presume you mean in the issue search and not in the board).

You can work around this issue with a listener (documented here)

I hope this helps!

Steve

Thanks for your reply.  What if I try to reindex the issue at the end of scripted field code?


So. What type of listener I need to use. To calculate the difference between update date and today?

thanks

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

78 views 0 4
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