Good afternoon all!
I have this question, an user is asking to create a rule to create a new issue based on data from trigger issue in a different project.
The problem I have is that information that he needs includes comments. He wants to copy all comments (or internal notes only if it's possible) to this new issue in project AA
How can I copy the comments? maybe including a json? how should it be?
thanks in advance,
Ro
The issue comments are a list smart value, and so you could iterate over them to add to the new issue. Please look here for information about the field: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--issue.comments--
Next, you asked about filtering to only copy the internal ones. That can be done by using smart value, list filtering. There is an example of filtering on internal comments in this article: https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588
Kind regards,
Bill
Thanks @Bill Sheboy
I have another question (sorry! but never worked with comments on automation)
can I copy the comments from the original to the new issue? Because I have try to copy to a custom field, and worked but do not know how to copy the original comments using smart values you suggested into the comment section in the new issue.
Is there any way? or should I use this custom field?
thanks in advance
Ro
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Ro!
Although you could use a custom field to store the copy, you could also add them as comments, either as one giant comment to the new issue or one-by-one (with an advanced branch). If you take a look at those links I provided they show examples of how to iterate over the comments list for an issue. For example:
{{#issue.comments}}
Comment by: {{author.displayName}} at: {{created}}
{{body}}
{{/}}
Please note: if you copy them with an automation rule, there is currently no ability to sort a smart value list. That means when you add the comments they will appear in a random order relative to the comments' date/time added. If you want them in the order they were added, please investigate a marketplace addon, as @John Funk suggested.
Thanks,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still don't know where to put this and how.
I do not have "Comment" field available on "choose field to set". So, how can i associate:
{{#issue.comments}}
Comment by: {{author.displayName}} at: {{created}}
{{body}}
{{/}}
to the comment field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After the issue is created, you may branch to it and then use the Comment Issue action. For example:
{{#triggerIssue.comments}}
Comment by: {{author.displayName}} at: {{created}}
{{body}}
{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Bill, but this won't work for my scenario.
My scenario is:
I have an issue in project A and want to copy or clone to Project B, and all comments from issue in project A should be copy to the new issue in project B.
So when the Branch section is executed, it is looking for most recently created in the current project A (In the rule restricted to projects cannot be edited)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If this rule is running as a global/multi-project scope, I believe that would still work.
If the most-recently-created branch does not work, a global/multi-project rule could still use JQL for your created issue key for the branch.
Please note, that there are execution limits per month for global/multi-project rules, so check with your site admin to confirm your limits before trying a global rule.
A more elaborate work-around which does not require a global/multi-project rule is to call the REST API from a web request in the rule to add the comments.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Bill Sheboy
In this context, can you please help me to understand why the system doesn't take my comment as needed.
In my automation rule, everything work well.
I have one Story automatically created with its sub tasks.
For this story I need to copy the last comment of my trigger issue.
So in the story I use the action ADD COMMENT and in the comment field I use the smart value {{issue.comments.last.body}}
But it doesn't return me my last comment in the trigger issue.
Is there an obvious mistake that I am making ?
I also tried other smart values like {{triggerIssue.get(0).comments.last.body}} or {{triggerIssue.comments.last.body}} but I have nothing.
It doesn't understand the issue that I want in fact. I will make also the start of my rule so you can see when it starts. After my JQL states and transitions are done my automation starts.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In fact it can be done, if at the beginning of our rule we can clone the trigger issue, so after we can track it. But in cloning the problem is, that by default it will not clone the comment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This smart value worked. Try this one @Rosana Casilli
{{triggerIssue.key}}:
{{triggerIssue.comment.last.body}}
But make sure that it is a trigger issue.
@Bill Sheboy thank you and sorry to disturb you. I could find the solution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No worries, and I am glad to learn you figured it out!
And as an FYI...as this is an older post, it can help to create a new question and link back to the older ones for context. Otherwise only the people mentioned or following the older threads will see it, limiting the suggestions you may receive.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also use this for copying comments from the trigger issues. But if the trigger issue has no comments this causes an error. Do you have an idea how to add a condition to avoid this?
{{#triggerIssue.comments}}
Comment by: {{author.displayName}} at: {{created}}
{{body}}
{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Andrea Rose
There are at least two ways to do this check:
{{#if(triggerIssue.comments.size.gt(0))}}
{{#triggerIssue.comments}}
Comment by: {{author.displayName}} at: {{created}}
{{body}}
{{/}}
{{/}}
Without seeing your complete rule, it is unclear the better way to use.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rosana,
We actually use the add-on called Deep Clone to do this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you john! but there is no budget for add-on right now.. :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.