Adding a Follower to a Ticket from a User Lookup Field | Community
Skip to main content

Adding a Follower to a Ticket from a User Lookup Field

  • June 17, 2024
  • 13 replies
  • 0 views

Hannah12

Is it possible to have the lookup relationship field add the agent/admin selected as a follower on a ticket? If so, how would one go about doing this? I can't seem to figure this out in the triggers, and the only other closely related setup I saw involved adding a tag to the ticket via macro then using a webhook trigger to remove the tag and add a follower from the organization.

here is our specific use case:

 

The User Lookup field in on the user profile. An agent, when they are going on vacation or will be out of office for PTO, will use the Out of Office app to flag themselves as OOO. Then, they can choose an Out of Office delegate (custom user Lookup Relationship field). When the agent is flagged as out of office and a ooo delegrate is present, then add that delegate to the ticket followers. 

Please let me know if there are any additional questions.

13 replies

Hannah12
  • Author
  • June 18, 2024

Hi @gregory chavez11 ,

Thank you! This was exactly what I was theorizing based on what I was finding in the community and other ZD blogs. I've decided to create a trigger that applies a tag to the ticket when the system sees that an agent is flagged as out of office. 
Another trigger would then activate a webhook that adds the delegate as a follower. 

The issue i'm running into it that I am not able to get the webhook to apply the delegate in the user relationship lookup field to the follower field. Would you be able to assist? Here's the code I have currently:

 

 

As you can see I also tried using the Add Follower using the Link Ticket to User (Look Up) > Out of Office Delegate option. It's hard trying to setup a trigger using relationship lookup fields as it creates multiple instances if there are other lookup relationship fields in the system. 

You help is GREATLY appreciate. 


Jacob20
  • June 20, 2024

Hi @hannah12  👋

 

The placeholder in your JSON body may be an/the issue. 

If you are looking to reference a field on the ticket assignee, the placeholder should look something like: {{ticket.assignee.custom_fields.out_of_office_delegate.id}}.


Hannah12
  • Author
  • June 20, 2024

Hello @jacob20 - Thank you so much for your help. It's GREATLY appreciate. 

I put that placeholder into the Test Webhook JSON box and no follower was added to the ticket. 

Here are some screenshots:

{
    "ticket": {
        "followers": [
            {
                "user_email": "{{ticket.assignee.custom_fields.out_of_office_delegate.id}}@domain.com",
                "action": "put"
            }
        ]
    }
}

OR
{
    "ticket": {
        "followers": [
            {
                "follower_id": "{{ticket.assignee.custom_fields.out_of_office_delegate.id}}@domain.com",
                "action": "put"
            }
        ]
    }
}

 

 

 

 


Jacob20
  • June 20, 2024

Hi @hannah12 

 

Are you getting the expected output from using that placeholder? 

You should be able to test that in a ticket comment where the assignee has a value in that field.

 

The placeholder documentation is not fully clear to me about the ID in “The ID of the target record in a lookup relationship field” is a reference to.

 

Assuming it is the External ID of the object record, is that also the output you're getting?

 

I'm new to lookup fields and custom objects, so I may soon be running low on helpful tips 🙂. 


Hannah12
  • Author
  • June 20, 2024

@jacob20  - 

 

I used the following placeholder in the first blank comment {{ticket.assignee.custom_field.out_of_office_delegate.id}} and the following placeholder in the second blank comment {{ticket.assignee.custom_field.out_of_office_delegate}}.

I am completely new to custom objects/custom user fields as well so your help is appreciated. 

 


Hannah12
  • Author
  • June 20, 2024

@jacob20  -

I figured out the placeholder!

{{ticket.assignee.custom_fields.out_of_office_delegate.id}} or {{ticket.assignee.custom_fields.out_of_office_delegate}}

 

I was forgetting the s in fields in my above statement. The problem now is I can't get the webhook to input the follower. D:

{
   "ticket": {
       "followers": [
           {
               "follower_id": "{{ticket.assignee.custom_fields.out_of_office_delegate.id}}",
               "action": "put"
           }
       ]
   }
}


Jacob20
  • June 20, 2024

Nice catch with the missing S 🙂👍

Looks like you need to replace “follower_id” with “user_id”, like this:

{
   "ticket": {
       "followers": [
           {
               "user_id": "{{ticket.assignee.custom_fields.out_of_office_delegate.id}}",
               "action": "put"
           }
       ]
   }
}


Hannah12
  • Author
  • June 20, 2024

@jacob20  -

Thank you! Unfortunately that didn't work. I wanted to test the webhook to enter a generic follower using a hard coded email and this worked

{
   "ticket": {
       "followers": [
           {
               "user_email": "katie.holt@companydomain.com",
               "action": "put"
           }
       ]
   }
}

However, when I try adding the {{ticket.assignee.custom_fields.out_of_office_delegate.id}} or {{ticket.assignee.custom_fields.out_of_office_delegate}}@companydomain.com and it still does not apply. 

:( 


Jacob20
  • June 21, 2024

Hi @hannah12 

 

Are your placeholders rendering the expected output in other contexts, like if you add it to a comment on a ticket that has an assignee with a value in that field?
"{{ticket.assignee.custom_fields.out_of_office_delegate}}@companydomain.com" 

 

Possibly it would make a difference if you use liquid markup to stitch together a value that can be used in this context. 

Something like:  

{{ ticket.assignee.custom_fields.out_of_office_delegate | append: "@companydomain.com" }}


Hannah12
  • Author
  • June 21, 2024

@jacob20 

I absolutely appreciate your help and effort into helping us solve for this problem. You are SO appreciated.

After posting my initial comment, I figured out how to edit the liquid markup to replace the whitespace with a period to create a “correct” email address. 

I've asked a lot of you, but if you could help me put both JSON and liquid markup together, I would be eternally greatful. 

{
   "ticket": {
       "followers": [
           {
               "user_email": "{{ ticket.assignee.custom_fields.out_of_office_delegate | replace: " ", "." | append: "@companydomain.com" }}",
               "action": "put"
           }
       ]
   }
}

This returned an internal server error: 


I know i'm doing something horribly wrong here, but I am EXTREMELY out of my element. 


Jacob20
  • June 21, 2024

Hey @hannah12 

 

No worries. 

I tried setting up a trigger to fire a webhook with a similar payload at the tickets endpoint. It worked for me.

 

A few thoughts on what you could check or confirm.

  • The user who's email you're adding to the followers list, this is an agent, correct?
  • Your screenshot suggests that you may be using the “test webhook” feature in admin center, you would need to create a trigger for the liquid and placeholders to render the output needed for a valid put request.

Hannah12
  • Author
  • June 21, 2024

@jacob20 - I GOT IT TO WORK.

I"M SO EXCITED


Jacob20
  • June 21, 2024

@hannah12 Awesome! Persistence pays off, well done! 

 

Have a great weekend!