Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Using a ScriptRunner Clone Issue Post Function, how can I set a comment on the cloned issue?

On Jira Software Cloud, I'm using the ScriptRunner Clone Issue Post Function to create a child issue automatically.

In the 'Additional Code' section I can update some fields for the cloned issue, for example:

issueInput.fields.summary = "Prefix " + issueInput.fields.summary;

However, I cannot seem to set a comment on the to-be-created cloned issue.

On Server, this was done as:

 

doAfterCreate = {
// Add Comment
    // dispatch an event after creating the comment
    final boolean dispatchEvent = true
    // the body of the comment
    final String commentBody = "Auto-generated Issue"
    // the author of the comment will be the logged in user
    def author = ComponentAccessor.jiraAuthenticationContext.loggedInUser
 
    ComponentAccessor.commentManager.create(issue, author, commentBody, dispatchEvent)
 
// Update Issue   
    issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}
What is the way to do this in ScriptRunner for Jira Cloud?
I appreciate your help!

1 answer

0 votes

Hi @Bert Dombrecht 

 

Please check this docs:

https://community.atlassian.com/t5/Jira-Software-questions/Jira-Cloud-ScriptRunner-How-to-add-comments-to-issues-in/qaq-p/1258613

https://www.youtube.com/watch?v=9gppxfiEhxU

 

Both links are not exactly what you need but you can see an example how to add comment in Jira Cloud.

 

Regards,

Seba

Hi @Sebastian Krzewiński 

Thanks for your reply.

The information you shared handles adding a comment to an already existing issue.
In that case I can indeed use post("/rest/api/3/issue/${issue.key}/comment")

However, the crux here is that I want to pass a comment to a issue that has not been created yet (during the Clone action), so there is no issue.key yet.

I was assuming I need to use issueInput.update somehow ...

Ask Script runner support. Maybe they will have solution for that.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Jira Software

👋 Looking for 15-20 volunteers to test Atlassian training content

Hi everyone! Are you interested in beta testing Atlassian University’s newest (unreleased!) training course? We’re looking for 15-20 volunteers to test our newest training course, Basic reporting...

395 views 19 22
Read article

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