Need to create a comment when closing Bug

CJ_Marchand
Contributor
July 18, 2023

Hi everyone,

I am still very new to Jira and I am not sure how to go about this task.  (Listener?  Behavior? Something else?)

I have a project lead who would like to automatically generate a comment when closing a BUG issue with a set of questions of what was done for the user to answer before saving. 

I found the code below (For a Behavior I believe) but in the statement on line 8, I do not have the issueID.

I did further reading and I believe I need to use ether the issueContext or underlyingIssue objects but am unsure of how to get a hook into ether of them. 

Am not sure if I am even on the right track. 

Is a behavior the right home for this?

How do i access the issueContext and underlyingIssue objects?

Thanks!

 

IssueID.PNG

2 answers

2 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Marco Brundel
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.
July 18, 2023

Hi @CJ_Marchand ,

I think it is possible to solve it with a behaviour. See screenshot as an example of a behavior that I succeeded with (sorry for the Dutch language in the example).

Regards, Marco Brundel

 

Screenshot 2023-07-18 at 16.18.47.png

CJ_Marchand
Contributor
July 19, 2023

Thanks for the response Marco.

0 votes
Answer accepted
Tim Perrault
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.
July 18, 2023

@CJ_Marchand 

 

I would actually use a Postfunction to add a comment. I would also do this on a step in the workflow before you close the ticket. To me if a ticket is closed it's closed. It won't get the attention that is needed because I am focusing on tickets that are not resolved and still "in progress".

CJ_Marchand
Contributor
July 19, 2023

Thanks for the response Tim.

Looking into Postfunctions now.

When adding the Postfunction “Add a comment to this issue” to the transition to “DONE”, will it allow the user to edit the comment before the issue is closed?  Or could they still edit the comment after it is close? 

They need to respond to some of the questions in the comment template about how they resolved the bug.

Tim Perrault
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.
July 19, 2023

It would not allow them to enter the comment during transition, but after they could.

 

Thinking about your requirements, I would tackle this differently. I would create a text multiline customfield. Then using behaviours, you could add default text with what you need. Have a little template. Then when you transition to do done have a screen with that field come up so the user can answer the questions.

 

def descField = getFieldById("customfield_xxxxx")

def descFieldObj = customFieldManager.getCustomFieldObject("customfield_xxxxx")

   

def defaultValue = """

Text goes here

""".replaceAll(/ /, '')


if (!underlyingIssue?.getCustomFieldValue(descFieldObj)) {

descField.setFormValue(defaultValue)

}

 

@Marco Brundellooks to have the same idea, but actually is working with the comments. The reason I say use a custom field is then one of the benefit is you can use it in searches and easily export if needed.

CJ_Marchand
Contributor
July 19, 2023

The customer requested a comment but I do not see why they would reject a CF.  Especially with the added benefits you state.

The field could be hidden till needed.

I think I will contact the Project Lead and see if he can live with a CF rather then a comment.

 

Thanks for the help from both of you.   

Like Tim Perrault likes this
TAGS
AUG Leaders

Atlassian Community Events