Best answer

Retrieve Most Recent Comment from Jira Service Desk

  • 17 March 2021
  • 3 replies
  • 24 views

Userlevel 1

I’m currently setting up a Zap to post comments from Jira Service Desk / Jira Service Management to a Zendesk ticket when the Jira Request is updated.

This was working pretty good! A zap first creates the request from Zendesk in Jira Service Desk and stores the Zendesk ticket ID in the request. Then when the request is updated in Jira, it updates the Zendesk ticket with the Jira Request Status and the comment.

But then I tried adding more than one comment to the Jira Request.

Instead of grabbing the most recent comment from Jira, it grabs ALL the comments on the request. Oops! From what I can tell, when using the field that would contain the text of the comment, Zapier is grabbing every instance of that field in the array that’s returned from Jira.

Does anyone have any insight on how to grab just the last item (most recent comment) from the array returned by Jira? Thanks!

 

The zap is currently set up as follows:

  1. Trigger: Updated Request in Jira Service Desk
    • App: Jira Service Desk
    • Trigger Event: Updated Request
    • Jira Service Desk account: our sandbox account (always test first!)
    • Site: our sandbox site
    • Project: our test project
  2. Action: Only continue if…
    • App: Filter by Zapier
    • Filter setup & testing: Only continue if…
      • Fields Customfield <ID>: Exists
        <ID> being the actual custom field ID from Jira that contains the Zendesk Ticket ID.
  3. Action: Update Ticket in Zendesk
    • App: Zendesk
    • Action Event: Update Ticket
    • Set up action
      • Ticket: [Fields Customfield <ID>]
        <ID> being the actual custom field ID from Jira that contains the Zendesk Ticket ID.
      • New Status: Open
      • New Comment To Add To The Ticket
        Ticket Updated in Jira Service Desk with the following comment:
        [1. Fields Comment Comments Body Content Content Text]
      • Should The First Comment be Public?: No
      • Jira Service Desk Request Status: [Fields Status Name]

And here’s an example of the output from the testing of the Jira trigger. (I’ve removed a lot of details that aren’t relevant to this issue.)

fields
    ...
    comment:
        comments:
            1:
                self: https://api.atlassian.com/ex/jira/<UUID>/rest/api/3/issue/<ID>/comment/<ID>
            id: <ID>
            …
            body:
                version: 1
                type: doc
                content: 
                    1:
                        type: paragraph
                        content:
                            1:
                                type: text
                                text: Testing an internal note to update this ticket.
            ...
            created: 2021-03-04T12:01:19.878-0600
            updated: 2021-03-04T12:01:19.878-0600
            jsdPublic: false
        self: https://api.atlassian.com/ex/jira/<UUID>/rest/api/3/issue/<ID>/comment
        maxResults: 1
        total: 1
        startAt: 0
    ...
originalId: <ID>

 

icon

Best answer by TravisTubbs 19 March 2021, 16:16

That was perfect, @Troy Tessalone! Thanks for pointing me in the right direction.

For those that are curious as to how this was accomplished, I did the following after the Update Request in Jira Service Desk step:

  1. Action: Create Loop from Text
    • App: Looping by Zapier
    • Action Event: Create Loop from Text
    • Set up action
      • Values to Loop
        • Name: text
        • Value: [1. Fields Comment Comments Body Content Content Text]
      • Text Delimiter: ,
      • Trim Whitespace: True
      • Loop Iteration Counter Start: 1
      • Maximum Number of Loop Iterations: 500
  2. Action: Only continue if…
    • App: Filter by Zapier
    • Filter setup & testing
      • Only continue if: Loop Iteration is Last, Boolean is true

The filter before updating the ticket in Zendesk is important as it will skip everything in the loop until the last item (comment), which what we want. Just need to remember to replace the New Comment To Add To The Ticket step in your Zendesk step with the text variable you created above.

View original

3 replies

Userlevel 7
Badge +10

Hi @TravisTubbs

One option to try might be to use the Looping action which would iterate thru each array item, but you’d limit it to run once: https://zapier.com/apps/looping/integrations

 

Solution may depend on a few factors:

  1. How the data is sorted (most recent first/last, most recently updated first/last, etc.)
  2. How the data is returned
  3. What data points you need
Userlevel 1

That was perfect, @Troy Tessalone! Thanks for pointing me in the right direction.

For those that are curious as to how this was accomplished, I did the following after the Update Request in Jira Service Desk step:

  1. Action: Create Loop from Text
    • App: Looping by Zapier
    • Action Event: Create Loop from Text
    • Set up action
      • Values to Loop
        • Name: text
        • Value: [1. Fields Comment Comments Body Content Content Text]
      • Text Delimiter: ,
      • Trim Whitespace: True
      • Loop Iteration Counter Start: 1
      • Maximum Number of Loop Iterations: 500
  2. Action: Only continue if…
    • App: Filter by Zapier
    • Filter setup & testing
      • Only continue if: Loop Iteration is Last, Boolean is true

The filter before updating the ticket in Zendesk is important as it will skip everything in the loop until the last item (comment), which what we want. Just need to remember to replace the New Comment To Add To The Ticket step in your Zendesk step with the text variable you created above.

Userlevel 2
Badge +3

@TravisTubbs that’s excellent news! Thanks for sharing your solution with the Community here!

Reply