Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Groovy script to track issue status changes in listener

Hi team,

 

I am looking for the groovy script to track the changes of status of an issue. I want to trigger some actions if at all the issue status has been changed. 

Can someone please help on the script to track this change?

1 answer

0 votes

A listener for this would need to be configured to trap and react to any event fired by your transistions, which might be a bit of a manual slog to work out all of them, but the alternative of putting a post-function into every transition is much worse.  In fact, I'd just listen for most events and then check "has status changed in this event"

You've not really said what you want to do with "track this change", but here's a pile of sample listeners for SR that might help you with some of it - https://library.adaptavist.com/search?term=listener

Hi @Nic Brough _Adaptavist_ 

Thanks for your reply.

I am writing this listener , whenever status of an issue is changed , I want to push some values to database.  

I am trying to do this with 'changeItem' and so looking for a help on the script line for the status change to be tracked.

Ok, I want to suggest a slightly different approach on a couple of points.

First, an event contains a whole load of information about the action that triggered it, and that's directly available to your listener code, so there's a good chance that you don't need to start messing with reading issues for data you already have in the event.

Second, you mention changeitem, which is the name of a table in a jira database.  In a listener, you have direct access to the api, which is a far better way to fetch Jira data than reading the database for raw data.  Reading a Jira database is the worst possible way to get data out of a Jira system.  

Now, bearing in mind the sequence of things that happen when you're talking about listeners, the bit we're interested in is:

  1. User says "yes, confirm this transition" (and it passes validation)
  2. Jira executes post-functions
  3. An event is fired
  4. Your listener sees an event and runs code because it saw one it should run for.  Almost all listeners use data in the event to process what they do

One thing that springs out here is that all the data that is going to go into the changeitem table is also in the event.  As well as the rest of the change information that's held in other tables in the database. 

So, use the event data in your code, forget the Jira database.

You say you want to "push some values to a database" - that's fine, but what values and what database?

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Events near you