onTicketUpdate & Custom Fields

Hello,

I’m trying to figure out “onTicketUpdate” it reacts as it should. I read that custom fields would not trigger this event. That is OK for now, but I cannot retrieve the information inside a custom field.

exports = {
  events: [
    { event: "onTicketUpdate", callback: "onTicketUpdateCallback" }
  ],
  onTicketUpdateCallback: function(payload) {
    var ticket_id = payload.data.ticket.id;
    var ticket_cf_casetypecode = payload.data.ticket.custom_fields.cf_casetypecode;

The var “ticket_cf_casetypecode” shows up as undefined. I’m guessing my sentence is the wrong but can not figure out where I am going wrong.

Sugesstions?

2 Likes

Hi @Octopus,

You may have to make an additional API call to Freshdesk Tickets API to make an additional API call and get the information that is part of custom fields.

We are actively seeking feedback from developers on similar cases like this. Please upvote it on the forum, it will help us get attention from the app platform team.

2 Likes

Hi @Octopus

I believe you are missing the account id suffix that the :freshdesk: event payloads contain. Could you perhaps log the entire payload once to get an idea of the custom field structure?

Hopefully that should be the case.

2 Likes

Hello @prithvi,

Guessing I need to make an api call to get the rest of the information. The part that I do not like about this, is that this acctually works our of the box using automations in freshdesk gui. Or hopefully Im just missing something.

@Octopus
The Freshdesk API returns a custom fields as the following:

cf_serienummer: null

The serverless payload contain the same custom field in this kind of keys:

cf_serienummer_123456: null

where cf_serienummer is the custom field name you get from the Freshdesk API and 123456 is the account ID of the specific Freshdesk instance that you have.

My suggestion was to log the complete backend serverless event payload to get an idea about the above mentioned format. There is a structural difference between how Freshdesk API returns the custom fields and how the serverless event payload has those same keys.

I can guarantee that there the necessary custom field data is present in both cases.

Hope this clarifies it a bit

2 Likes

@prithvi - I can not even explain it, answer was so easy. If that had been documentet somewhere. I think I read a lot of information under freshdesk developer - but that was news to me.

I changed my app a bit, and sent my self the complete info just to get the account number and well a hole lot of info.

Thank you a lot for this @prithvi

2 Likes