Forums

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

Reopen a ticket when there is a comment within 2 days when its in closed/resolved state

Arun Chatterjee February 1, 2023

Hello there, we are using Jira Server and will be migrating to Data Center soon.

We have access to SIL scripts.

How can we achieve this requirement. I have very limited knowledge in Groovy/SIL. Does anyone have a sample script or a pre-existing template or similar for this requirement? It would help me.

 

Thanks,
Arun.

3 answers

1 accepted

2 votes
Answer accepted
Anna Hryhoruk _Appfire_
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.
February 7, 2023

Hello Arun!

Indeed, it`s something we can do with SIL. I would even say that there may be few different approaches to configure that, but let`s consider one with SIL Listener. 

The idea is to have SIL listener that will be triggered when issues are commented. In the script running on that event, we will check if the issue is in done status and for how long the ticket is in done status and if it`s less than 2 days the reopen transition is performed. 


So, you need to configure SIL Listener that will be triggered by event "Issue Commeneted". Here you can find more information how to add SIL Listener 

The script that is used for this Listener should be something like this: 

string field_name = "status";
string[] field_history = fieldHistory(key, field_name);
number n = arraySize(field_history);
date startDate;
startDate = arrayGetElement(field_history, n - 2);
if (n > 0 and status =="Done" and ((currentDate() - startDate) <= "24h") ) {
autotransition("Reopen issue", key);
}

 Please pay attention that status name "Done" and autotransition name "Reopen issue" should match names in your Jira and need to be replaced if those are different from my example.  Also, if you have any conditions or validators on that transition, you may need to add extra parameters to the autotransition routine

 autotransition(transition, issueKey [, skipConditions, skipValidators])

I am also adding documentation page about this autotransition routine  

Hope it helps!
Anna

0 votes
Arun Chatterjee February 21, 2023

hey @Jeroen Poismans

we don't have Jira Automation in our server. hope we get it when we update the Jira.

@Anna Hryhoruk _Appfire_ , is it possible to run the script as the person who commented. because it would look neat, to reopen the ticket as the person who commented.

i used this script for something similar, and i also want to achieve a another similar thing. i'm doing a transition from 'Awaiting Response' to 'In Progress'. But the transition should be done by the ticket 'Assignee'.

your script definitely helped. just need these two modifications. any help would be great.

i could do something similar in SIL listener in the "if you want to run the script as a user, select one' but that seems to be just static.

thanks,

Arun.

Anna Hryhoruk _Appfire_
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.
February 21, 2023

Hello @Arun Chatterjee ,

Happy to hear that it was helpful!

yes, running this listener as a user who commented is possible. You need to add this single line to be the first line in your script:

runAs(argv[0]);

+ adding some documentation for this routine runAs  

For the use case with the assignee, if the similar script is running as a Listener too, you can use a similar approach, just add to the beginning


runAs(assignee);

 However, the script will not be executed if the issue is "Unassigned" 

Hope this will provide you a solution for the use case. If yes, please do not forget to "Accept" the solution.
Best regards,
Anna

Arun Chatterjee February 21, 2023

Clean.

This is now in production. Thanks for the help, Anna.

Like Anna Hryhoruk _Appfire_ likes this
Anna Hryhoruk _Appfire_
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.
February 21, 2023

Great! Glad to help :) 

Anna Hryhoruk _Appfire_
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.
February 21, 2023

By the way, forgot to mention: 
If you like Power Scripts app and have just a second to give us a shout-out on the Atlassian Marketplace that would be awesome 
thanks! 

Like Arun Chatterjee likes this
0 votes
Jeroen Poismans
Community Champion
February 6, 2023

Hi there and welcome to the community!

Not sure if you need a script for this. I think this could be achieved with automation:

  • Trigger: Comment added
  • Condition: JQL checking the status history
  • Action: Transition issue Reopen

The JQL should look something like this (might need to change a little bit:

status in (Resolved, Closed) AND ((status changed TO Resolved DURING (startOfDay(-2), startOfDay())) OR (status changed TO Closed DURING (startOfDay(-2), startOfDay())))

Good luck!

 

Regards,

Jeroen

Suggest an answer

Log in or Sign up to answer