Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Frequency of Scriptrunner execution

Randy_Elias
Contributor
December 12, 2018

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

3 answers

2 accepted

1 vote
Answer accepted
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 12, 2018

>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.

Randy_Elias
Contributor
December 12, 2018

Thank-you for the response @Nic Brough -Adaptavist-!

A few questions for you:

  1. Is there another way you'd suggest to reset my custom field on an annual basis? (in order to remove the heavy load it would impose)
  2. When is an issue indexed?

 

Thanks,

   Randy

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 12, 2018

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!

0 votes
Answer accepted
Randy_Elias
Contributor
December 13, 2018

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

Ignacio Pulgar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 14, 2018

ScriptRunner's Escalation Services.

Randy_Elias
Contributor
December 14, 2018

Thank-you @Ignacio Pulgar!

That's exactly what I was looking for.

 

Cheers,

  Randy

1 vote
Ignacio Pulgar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 12, 2018

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?

Randy_Elias
Contributor
December 12, 2018

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

Suggest an answer

Log in or Sign up to answer