What is the right way to create a comment using ADF document stored in a smartvalue (Variable) ?

Ignacio Yaselli March 22, 2024

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"
        }
      ]
    }
  ]
}

2 answers

0 votes
Amit Sati
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 27, 2024

Hi @Ignacio Yaselli 

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.

0 votes
Jehan Bhathena
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 24, 2024

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.

image.png

What I would suggest to debug the issue is:

  • {{CommentBody}} display this value as a log action or a comment in a test ticket, and see if the value generated is in the required format

What usually happens is that smart values strip the spaces and new lines, making the value unusable in the API request.

 

Ignacio Yaselli March 25, 2024

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.

 

Jehan Bhathena
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 25, 2024

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

Ignacio Yaselli March 26, 2024

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 screenshotsScreenshot 2024-03-26 114908.pngScreenshot 2024-03-26 114630.png

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" } ] } ] }

 

Ignacio Yaselli March 26, 2024

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. 

Jehan Bhathena
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 26, 2024

HI @Ignacio Yaselli 

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?

Like Bill Sheboy likes this
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2024

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

Like Ignacio Yaselli likes this
Jehan Bhathena
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 26, 2024

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.

Like Ignacio Yaselli likes this
Ignacio Yaselli March 27, 2024

Hi All, 

 

thanks for your input. I have raised a support ticket and they are currently troubleshooting.

 

I will post the result here

Like # people like this

Suggest an answer

Log in or Sign up to answer