Hi All,
I am having a problem finding documentation on the right way of doing this.
I am setting an Automation on the Service Desk and my goal is to add a comment during the transition of a ticket. We have set comments mandatory when resolving tickets.
I have other use cases where I have a very similar problem.
I added the following code to the additional fields to modify during the transition:
{
"update": {
"comment": [
{
"add": {
"body": {{CommentBody}}
}
}
]
}
}
If the value of {{CommentBody}} is “Nice Work”, the automation runs successfully.
However, If I replace the value of {{CommentBody}} with a Valid ADF Document, then I get the error:
(Operation value must be an Atlassian Document (see the Atlassian Document Format) (comment))
CommentBody is a variable set up in the Automation and is accessible as smartvalue using {{CommentBody }}
For reference, I have used the ADF builder to generate the wanted JSON code, which I pasted as the value of the smartvalue.
Example, for the text:
Hi Ignacio,
We haven't heard back from you for 10 days, so we're automatically closing this support request for now.
Please feel free to re-open or comment on this issue if you still need help!
Best Regards,
Automation for JIRA
The resulting JSON is
{
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Hi Ignacio,"
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "We haven't heard back from you for 10 days, so we're automatically closing this support request for now."
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Please feel free to re-open or comment on this issue if you still need help!"
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Best Regards,"
},
{
"type": "hardBreak"
},
{
"type": "text",
"text": "Automation for JIRA"
}
]
}
]
}
Try using Automation Action: Send Web Request: https://community.atlassian.com/t5/Jira-Software-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828
Use the below ADF for Custom Data under Send Web Request:
{ "body": { "content": [ { "type": "codeBlock", "attrs": {}, "content": [ { "type": "text", "text": "Hi Ignacio,\n\nWe haven't heard back from you for 10 days, so we're automatically closing this support request for now.\n\nPlease feel free to re-open or comment on this issue if you still need help!\n\nBest Regards,\nAutomation for JIRA" } ] } ], "type": "doc", "version": 1 } }
And yes this will also work with Postman.
HI @Ignacio Yaselli ,
I tried the JSON you've pasted, and it works fine at my end when using it as the body in Postman's API request.
What I would suggest to debug the issue is:
What usually happens is that smart values strip the spaces and new lines, making the value unusable in the API request.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, yes, the payload works well via postman, but for some reason it does not when using Automation. I should have made that obvious, but I have failed to mention it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share a snapshot of your automation setup?
Along with the value that gets resolved for the {commentBody} smart value.
Might help us identify the issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jeham, thanks again.
I created a manual automation that focusing on generating the comment body and edits the fields. Same issue. please look at the screenshots
LOG:
{ "version": 1, "type": "doc", "content": [ { "type": "paragraph", "content": [ { "type": "text", "text": "Hi Ignacio Yaselli," } ] }, { "type": "paragraph", "content": [ { "type": "text", "text": "We haven't heard back from you for 10 days, so we're automatically closing this support request for now." } ] }, { "type": "paragraph", "content": [ { "type": "text", "text": "Please feel free to re-open or comment on this issue if you still need help!" } ] }, { "type": "paragraph", "content": [ { "type": "text", "text": "Best Regards," }, { "type": "hardBreak" }, { "type": "text", "text": "Automation for JIRA" } ] } ] }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
By the way,
As a work around, I replaced the CommentBody with the string:
"Hi {{theReporter}},\n\nWe haven't heard back from you for 10 days, so we're automatically closing this support request for now.\n\nPlease feel free to re-open or comment on this issue if you still need help!\n\nBest Regards,\nAutomation for JIRA"
When I do this, it works, in so far that the output is what I expect. However, it looses the flexibility that ADF can provide, or should provide.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the insights.
What I could make out is that Comments cannot be added using the ADF format in the "Advanced" Edit issue option.
If you go thru https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Why-is-my-field-not-editable, it mentions that any field listed under the createmeta API can be edited using the UPDATE or SET.
You can try this API at your end too : https://<site url>/rest/api/3/issue/createmeta?projectKeys=<Project Key here>&issuetypeNames=<Issue Type here>&expand=projects.issuetypes.fields
My site did not return COMMENTS in this list, and we cannot add this field in the Screens either.
@Bill Sheboy would u happen to have any insights to this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ignacio Yaselli and @Jehan Bhathena
I have not tried using the ADF format with comments in an automation rule's JSON update before. My suggestions are...
Perhaps try using the editmeta parameter to determine if there is something incompatible in what you are sending relative to what is permitted:
<your Jira URL>/rest/api/2/issue/<example issue key>?expand=editmeta
Next, try searching in the developer community for use of ADF with comments to learn if there are known issues: https://community.developer.atlassian.com/
Finally, as I do not see anything in the rule documentation about use with ADF, perhaps ask that question directly to Atlassian Support: can the ADF format be used with automation rules in JSON during issue create / edit? Your site admin can submit the support ticket here: https://support.atlassian.com/contact/#/ Once you hear back from them, please post what you learn to benefit the community. Thanks!
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.
Thanks for your inputs Bill :-)
I tried to look for any documentation pertaining to this but didn't find any @Ignacio Yaselli , you may want to consider raising a support ticket to get a concrete response on the request.
The solution that you've posted here https://community.atlassian.com/t5/Jira-Software-questions/Re-Re-What-is-the-right-way-to-create-a-comment-using-A/qaq-p/2652328/comment-id/934950#M934950, is the documented way as per https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/#Field-syntax-examples
You may want to try the Comments API call to see if this helps. Reference: https://community.atlassian.com/t5/Jira-Software-questions/Re-Re-Jira-Automation-How-to-send-new-comment-via-Web/qaq-p/2474911/comment-id/691058#M691058
Do let us know how it goes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
thanks for your input. I have raised a support ticket and they are currently troubleshooting.
I will post the result here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, I've only just found this post, as I've been working on Comments and @Mentions on issues, and started down the ADF rabbit hole too.
I'm using scriptrunner, and as such have coded Post-Functions into my workflows that have allowed me to automate comments, and @mentions. (though I'm struggling to get the format right for a Team mention still).
I've used the Jackson library to help me build the ADF, then I debug it in both a JSON formatter, and the ADF playground. That's helped me get the right formats, and pass them to the v3 API with good success via a payload object of the JsonNodeFactory.
Hopefully this could be helpful. Let me know if you need lower level detail. (not sure it's applicable to automation)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.