Forums

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

Automatically add a Comment

CHINNAMUTHEVISAI.SATYANARAYANASHARMA
Contributor
May 24, 2022

we have one requirement i.e
when in Parent Jira ticket which is story issue type in workflow if we click a fail transition it should create new issue type Bug. which is  completed .

but what i am looking here when new issue created which is bug(Child) the newly created child ticket summary has to be copied as a comment to parent ticket

is that possible ?

my automation plug in was expired we have JSU, Script runner and Jira Misc plugin.

1 answer

0 votes
Vikrant Yadav
Community Champion
May 24, 2022

Hi @CHINNAMUTHEVISAI.SATYANARAYANASHARMA  You can do this easily with the help of JSU plugin. Use Post function >> Copy field value.
Select Issue relation Linked issue >> select the link type 
Copy field Summary to ***new comment***

Try this it should work.

 

Add comment JSU.PNG

CHINNAMUTHEVISAI.SATYANARAYANASHARMA
Contributor
May 24, 2022

Applied same on parent workflow but getting comment on child case.

this post function has to be applied on parent ticket or child ticket ?

Vikrant Yadav
Community Champion
May 24, 2022

Hi @CHINNAMUTHEVISAI.SATYANARAYANASHARMA  Yes, post function should be on parent issue. It seems that you selected the wrong issue link relation. Check issue link relation, select correct link type.

Thanks

CHINNAMUTHEVISAI.SATYANARAYANASHARMA
Contributor
May 24, 2022

transition.PNG

applied same post function on parent workflow still its not getting commented.

Vikrant Yadav
Community Champion
May 24, 2022

May I know which link type are you using when creating child bug issue ?

CHINNAMUTHEVISAI.SATYANARAYANASHARMA
Contributor
May 24, 2022

link type is bug only bug.PNG

Vikrant Yadav
Community Champion
May 24, 2022

Select link type bug instead of Related to . 

sai chinamuthevi
Contributor
May 24, 2022

Sorry for commenting from other account

 

That's also done before raising this ticket but not working too.

Vikrant Yadav
Community Champion
May 24, 2022

Move post function after child issue creation post function. 

Bug is a link type, right ? 

Thanks

sai chinamuthevi
Contributor
May 24, 2022

Yes bug is a link type

Vikrant Yadav
Community Champion
May 24, 2022

I have tested on my side using Parent/Child Link type. it's working fine. Comment is adding on Parent issue (Story). It seems that you are doing something worng in issue lik relation in post function. Please make sure, Add comment post function must be after create issue post function.is parent of.PNGIssue link.PNG

 

Thanks

V.Y

sai chinamuthevi
Contributor
May 24, 2022

Thanks 

In place of is parent of bug should be added right ?

Vikrant Yadav
Community Champion
May 24, 2022

Yes...Bug ..

CHINNAMUTHEVISAI.SATYANARAYANASHARMA
Contributor
May 24, 2022

Hi Vikrant,

 

it's working fine for me at the moment but i need a default format that needs to be generated when bug(child) has been created in parent ticket.

at the moment child ticket summary has been copied as a comment in parent ticket but the required format is like this

Ex- A new bug has been created

Reference: SF-1234  ( newly generated child issue key)

Summary: Unexpected item in the bagging area.

 

is that possible ?

Vikrant Yadav
Community Champion
May 25, 2022

@CHINNAMUTHEVISAI.SATYANARAYANASHARMA  It's not possible to add Issue key in a comment using JSU automation suite. Kindly use Scriptrunner post function to add custom comment on an issue. 

 

Add a comment to this issue [ScriptRunner]

OR 

Adds a comment to linked issues when this issue is transitioned [ScriptRunner]

 

Thanks

V.Y

CHINNAMUTHEVISAI.SATYANARAYANASHARMA
Contributor
May 25, 2022

Thanks Vikrant,

 

can you mention the script if possible.

we are able to match our requirement here.

but we are getting two comments one is with issue summary and other is with newly created issue key can we combine both and add as a one commentCapture.PNG

Vikrant Yadav
Community Champion
May 25, 2022

Try to add Custom scripted post function of adding comment having linked issue key and bug summary :- 

Kindly check link type of Bug in issue linking, if it's Outward change getInwardLinks to getOutWardLinks and change commentBody as per your requirement. 

import com.atlassian.jira.issue.link.IssueLink

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.issue.comments.CommentManager

def issueManager = ComponentAccessor.getIssueManager()

def commentManager = ComponentAccessor.getCommentManager()

def issueLinkManager = ComponentAccessor.issueLinkManager

List allOutIssueLink = issueLinkManager.getInwardLinks(issue.id);

for (Iterator outIterator = allOutIssueLink.iterator(); outIterator.hasNext();) {

IssueLink issueLink = (IssueLink) outIterator.next();

def linkedIssue = issueLink.getSourceObject();

def bugkey = linkedIssue.getKey()

String issueName = linkedIssue.getSummary()

// dispatch an event after creating the comment

final boolean dispatchEvent = true

// the body of the comment

final String commentBody = """New Linked issue has been created ${bugkey}

${issueName}"""

// the author of the comment will be the logged in user

def author = ComponentAccessor.jiraAuthenticationContext.loggedInUser

ComponentAccessor.commentManager.create(issue, author, commentBody, dispatchEvent)

}

Thanks

V.Y

Suggest an answer

Log in or Sign up to answer