Hi,
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".
Thanks,
Michael
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am wondering if you could use automation to achieve your goal. Are use automation in some rules to compare a date to today’s date without having to have a custom field displays today’s date. You might check the Automation documentation for this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jack, many thanks.
We have JIRA server and according to Atlassian, automation is not actively available for Server customers....
Alternatively, I am also fine if another CF "Delayed?" displays "Yes" or "No".
Can you help?
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry I missed that you were on server. You’re gonna need some sort of ad on the manage these dates and custom fields. Not a ure I can really help you beyond that.
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.