Forums

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

How can I automatically count the number of times a "date" type custom field is updated?

Denna Cummings July 27, 2022

Hi there,

For example, I would create a custom field "Admin Count". I want the "Admin Count" field to count the number of times the "Close Date" field was updated within the ticket.

The idea is for the "Admin Count" field would start at "0" when the initial "Close Date is set. The field would increment each time it changes/updated by 1.

I'm using JMWE to work on this task by using a scripted field post function. Any feedback would be greatly appreciated.  

Thank you for your time! :-)

 

2 answers

2 accepted

4 votes
Answer accepted
Dimitris Ballas
Contributor
July 27, 2022

Hi Denna,

The best way to achieve that is using Automation for Jira add-on.

You can create a rule which will be triggered by the Field Value Change of your date field and then use the math smart values as described here (https://confluence.atlassian.com/automation/working-with-numbers-993924632.html) to increase the value of the count.

Another solution could a Scriptrunner Listener as well.

I hope this helps!

Denna Cummings July 27, 2022

Hi Dimitris,

Thank you so much for your reply! I will go take a look at keep you updated. 

Denna Cummings July 27, 2022

Hi Dimitris,

Also, I'm also wondering if there is another way besides Automation? Scriptrunner does not work well with our current system. I'm willing to try additional ideas. 

Dimitris Ballas
Contributor
July 27, 2022

If you don't want to use Automation or Scriptrunner, then my next suggestion would be to have a look at the ChangeHistoryManager method and try to use it in a JMWE script post-function to gather all the changes on the field, count them and increase the "Admin Count" field accordingly.

Please note that the "Admin Count" will not be updated live (after any change on the date field) but only after you run the transition which holds the JMWE post-function.

Like Denna Cummings likes this
Denna Cummings July 27, 2022

Dimitris,

That is good to know! I will try and test it.

0 votes
Answer accepted
David Fischer
Community Champion
July 27, 2022

The easiest would be to use our JMCF app, which allows you to create calculated fields, which is exactly what you're trying to create. 

Barring that, you can use a JMWE post function inside either a workflow transition or a JMWE event-based action. 

Denna Cummings July 27, 2022

Thanks David!

Suggest an answer

Log in or Sign up to answer