Need help with a Script to return the difference between current date and due date (field of issue )
if the value of the difference is 0>diiff<=7 then should return one value
if the value of the difference is 7>diiff<=14 then should return one value
if the value of the difference is 14>diiff<=21 then should return one value
these values supplied should go in one custom field or 3 different field cant decide .
then these dynamically changing Scripted custom field should be reflected in the dashboard showing that an issue is due in one week ,two , three . so as to take action depending on due date .
This is not going to work.
Jira data is is intended to track change. The data does not change based on time, it changes based on when people (or processes) change it.
"now" is always changing, so a script to recalculate the difference between due and now would have to run over every issue in the system once a second (a second is the smallest time Jira code bothers with, but it's not well used and humans rarely see anything more granular than a minute)
So, there aren't any scripts to do this.
You will need to have a re-think and work out some way to do this without constant recalculations. As an example, an app that reports on a list of issues could look at the due date, compare it with "now" while it is being rendered and choose to display differently depending on the difference. That would only run when someone runs the report, so it's not dependent on saving data for issues.
Maybe i will try to write a schedule job for it and run the script at that particular time of the day so now ()only executes during the schedule time of the job . The main problem is the script. How do i write the Logic where the script returns the value for three different conditions to three different numeric custom field
When you're new to coding, it can be good to look at what others have done and learn from that. It's also useful for expert coders too, saves them "re-inventing the wheel".
Ideally simplified stuff, code that tries to do one thing well. For Scriptrunner, I lean on https://library.adaptavist.com
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