Hi All,
I have a Groovy Scriptrunner script that resets a JIRA custom field to 0 on a specific date and time every year. I use the compareto() date function to test the current date and time to the trigger date and time to reset the value.
Will the scriptunner listener trigger the reset at the specific date and time?
Or does it get executed only when the JIRA issue is opened?
Not sure how this part of Scriptunner works.
Thanks for your help.
Cheers,
Randy
>In the scripted field, I get the current Date and compare it with a specific Date (ie Apr 1st) of the current year. If they are equal, I reset a custom field to be "0".
Do not do this. A scripted field is NOT there to try to amend data, it is there to calculate a value for display (to answer the question though - a slight oversimplification is that you can assume your script will run every time an issue it is on is indexed). Amending other data imposes a heavy load, and can lead to loops and a broken index.
If however, your field just calculated the number and displayed it as the output of the scripted field, that would be fine. But you'd need to index the issue to get it to work. A service could do that.
Thank-you for the response @Nic Brough -Adaptavist-!
A few questions for you:
Thanks,
Randy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would lean towards a service - one that runs daily, early in the morning and runs a filter to find the issues that need updating based on their date. In fact, if it's a fixed date, you could run it annually and have it update them all in one go. It's still a bit of a load, but it'll only run once per issue and it'll just churn through them.
Issues are indexed on any changes made to them!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Building on Nic's comment, does anyone know of a JIRA service (or plugin) one can use to update a custom field at a specific date and time?
Kinda sounds like a cronjob of sorts.
Thanks,
Randy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ScriptRunner's Escalation Services.
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.
A Script Listener is not the best option here. A scripted field seems to be better, at least with the info provided so far:
https://scriptrunner.adaptavist.com/5.4.43/jira/scripted-fields.html
What are you trying to achieve exactly?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply @Ignacio Pulgar.
I wasn't clear with my explanation. Actually, I am using a scripted field.
In the scripted field, I get the current Date and compare it with a specific Date (ie Apr 1st) of the current year. If they are equal, I reset a custom field to be "0".
I'm just not sure how often the scripted field is executed to do the date compare.
Thanks,
Randy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.