I am looking for the script to make sure that a custom field e.g. "Today" displays always todays date e.g. May 07, 2021 without making any update on the issue itself.
Can anyone help and explain what to do exactly? Not sure if I have to use a scripted field, behavior or anything else.
I need to use this field to make a comparison later on between two date fields e.g. "Today" and "Due Date".
You can do this with Scriptrunner (I'm taking a guess that you're looking at that because you mention Behaviours), but it's not going to do what you want very well.
This is because of what a field is - the content is something that is part of an issue. It does not change unless something changes it whether that's code or a human.
If you were to do this with a standard date field, then a script to populate it would be very simple, as all it would need to do is "put now() in custom field".
But, it will set the date to now when it is run. At midnight tonight, it then becomes wrong, because it's still going to hold today's date. So you would need to run a second script at midnight to find every issue it is populated on and update the issue, setting the field to the new date.
On server, you have the option of a scripted field, with a script behind it that's not a lot more complex than "return now()"
But again, that is fixed data and you'll need to update it at midnight every night. With a scripted field, you can have less impact - they don't store their data in the database and you can trigger and update with some code that just triggers a re-index on the issue without changing it.
Either way though, you're having to perform potentially large updates every night.
I would forget it and look at the comparison you are doing instead. Usually, people are doing comparisons in JQL, and that doesn't need a field to do what I think you are looking for. For example
duedate > now()
will list all issues with a due date after today.
Hello Community members! We’re wrapping up the end of JSM June with an Ask Me Anything (AMA) with the Jira Service Management product team. This is your chance to ask all your ITSM questions to o...
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