Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

identify attachements and comment that are created on a transition

yannis meriel April 29, 2015

Hi !

I have to perform special actions on certain attachments and comment, so I have created a transition where users can add attachments and a comment.

How can i identify/get in a database or a file the ID of the attachment and comments that are filled in a specific transition ? 

I read about post fonction using groovy script runner, but i'm not sure if it's really possible.

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
JamieA
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.
April 30, 2015

You will need to iterate through the issue change history (com.atlassian.jira.issue.changehistory.ChangeHistory) - in that you will the action ID where each attachment was added.

yannis meriel June 24, 2015

i'll try to write the script ( first time writing groovy for me, i may need some help after ^^ ) thx for the hint

0 votes
yannis meriel June 29, 2015

following jaimie's advice, i wrote this simple script and added it as a post function for a workflow transition :

import com.atlassian.jira.issue.changehistory.ChangeHistoryManager
import com.atlassian.jira.component.ComponentAccessor
ChangeHistoryManager chm = ComponentAccessor.getChangeHistoryManager()
def chg = chm.getChangeHistories(issue)
def id = 0
def taille = chg.size()
File file = new File("/test.xml")
for ( i in 0..taille)
{
    if (chg[i].getId() > id) 
    {
        id = chg[i].getId()
    }
}
String strLong = Long.toString(id);
file.write strLong

But with this i don't get the ID of the last change of the issue ( that just happened )  but i get the ID before the last change.

Am i missing something and am i in the right way ?

0 votes
Pedro Cora
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 29, 2015

If the attachments are only coming on an specific transition, you can use the transition ID (you can get that in the Workflow screen) and then craft your script to act when that transition happens.

yannis meriel April 29, 2015

Hi !

acting after the transition isn't a problem, for me it's the purpose of the post function right ?
the problem id to identify the attachments and comment added in the transition, on a file or on a table.
if i craft a script and use it as a post function, can i get in this script the attachments and comment (name or id)
added in the transition ?

Arianna Fabbri June 30, 2016

Hi @yannis meriel, have you found a solution for this?

 

Thank you

yannis meriel November 17, 2016

no i do not have a solution yet , but i'm working on it again.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events