Can i copy comments in activity of an issue.
Asked by Tushar Shinde:

Hi Team,

I wish to copy 'comments' mentioned in activity section of an issue to new issue which gets created via automation on placing parent issue in a particular column. I am able to copy other field of parent issue but cannot find option to copy comments.

Please help me achieve it.


Answers:
author: Jan-Hendrik Spieth
body: You can iterate over comments, via smart value: <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--issue.comments-->

And so you would iterate the comments and copy each one to the new issue.

I hope this gets you going :-)

comments: author: Tushar Shinde
body: HI Jan,

I tried both of the below codes in 'Additional Fields' :

{{#issue.comments}} Comment by: {{author.displayName}} at: {{created}} {{body}} {{/}}

as well as

"comment": \[ { "add": { "body": "{{#issue.comments}}  
Comment by: {{author.displayName}} at: {{created}}  
{{body}}  
{{/}}  
} } \]

as suggested by [@Sachin Dhamale](/t5/user/viewprofilepage/user-id/785689)

Both codes return error "Error while parsing additional fields. Not valid JSON." when published and triggered.

What could i be doing wrong here ? Please suggest.a


author: Jan-Hendrik Spieth
body: The snippet looks ok to me. It should work when you are using this in a branch, with action "comment on issue".

Can you give us a bit more context? How does your rule look like?


author: Luka Hummel - codefortynine
body: Hi [@Tushar Shinde](/t5/user/viewprofilepage/user-id/5195821)

If you are having trouble cloning issues via Jira automation and don't mind using a third-party app you can try our [Deep Clone for Jira](https://marketplace.atlassian.com/apps/1218652/deep-clone-for-jira?hosting=cloud&tab=overview&source=community313) app.

If you still want to use Jira Automation to trigger a clone you also can do that with a looping transition and a Deep Clone post function as described [here](https://c49.link/deep-clone-for-jira/docs/looping-transitions).


author: Thibaut Subra _Elements_
body: Hello [@Tushar Shinde](/t5/user/viewprofilepage/user-id/5195821)

If you don't mind using a third party app, I can recommend our [Copy \& Sync](https://marketplace.atlassian.com/apps/1211111/elements-copy-sync-clone-jira-issues?tab=overview&hosting=cloud&utm_source=community&utm_medium=forum&utm_campaign=question-2370431) application that can help you with that. Our app allows you to copy and synchronize issues.

In your case, you can easily [copy](https://doc.elements-apps.com/copy-and-sync-jira-cloud/how-to/copy-an-issue-and-all-its-comments-or-attachments-at-the-same-time?utm_source=community&utm_medium=forum&utm_campaign=question-2370431) and [synchronize comments](https://doc.elements-apps.com/copy-and-sync-jira-cloud/how-to/synchronise-comments-or-attachments-between-an-issue-and-its-copy?utm_source=community&utm_medium=forum&utm_campaign=question-2370431) so you keep consistency between your issues. You can also [trigger your recipe directly with Automation](https://doc.elements-apps.com/copy-and-sync-jira-cloud/how-to/trigger-recipes-with-automation?utm_source=community&utm_medium=forum&utm_campaign=question-2370431) if you want to integrate specific actions in your flow.

Anyway, I will be glad to help if you have any questions! Don't hesitate to take a look, our app is free under 10 users or there is a 30-Day trial.

Regards


author: Sachin Dhamale
body: Hi [@Tushar Shinde](/t5/user/viewprofilepage/user-id/5195821)

Its little bit tricky

You need to use add comment action and add the smart value in that as mentioned by [@Jan-Hendrik Spieth](/t5/user/viewprofilepage/user-id/5077631)

Also try this

you can try this in automation rule use JSON value in additional field section

"comment": \[ { "add": { "body": "\<Here you can use the smart value mentioned by [@Jan-Hendrik Spieth](/t5/user/viewprofilepage/user-id/5077631) " } } \]

comments: author: Tushar Shinde
body: HI Sachin,

I tried both of the below codes in 'Additional Fields' :

{{#issue.comments}} Comment by: {{author.displayName}} at: {{created}} {{body}} {{/}}

as well as

"comment": \[ { "add": { "body": "{{#issue.comments}}  
Comment by: {{author.displayName}} at: {{created}}  
{{body}}  
{{/}}  
} } \]

as suggested by you. Both codes return error "Error while parsing additional fields. Not valid JSON." when published and triggered.

What could i be doing wrong here ? Please suggest. Thanks.


author: John Funk
body: Hi Tushar,

I am having trouble following everything that you are doing, but you should be able to use the smart value of {{issue.comments}} to get those comments. Or {{triggerIssue.comments}} dependending on how you are getting there.

comments: author: Tushar Shinde
body: Hello John,

I am trying to copy content from an issue in Project A to new issue that gets created in Project B via automation. Automation rule triggers when an issue is moved in a particular column. I am getting description, assignee, attachment and other details from parent issue. It's only the comments that i am unable to copy currently.


author: John Funk
body: Did you try {{triggerIssue.comments}}


author: Tushar Shinde
body: Yes, I tried it now. Getting "Error while parsing additional fields. Not valid JSON." error when automation triggers.


author: John Funk
body: Probably just better off using one of the add-ons like Deep Clone.


Tags: cloud

jira-work-management-cloud