---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Generate the payload for a new trouble ticket event

# Generate the payload for a new trouble ticket event {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

When adding a trouble ticket event to your implementation, you must create a function that generates the required TMF-compliant payload for that event type. In addition, you must add that function to the case statement that
directs the logic to this function when processing this type of event record.

## Create a method that generates the payload for the new trouble ticket event {#prd_evt_not-dev_gd-gen_evt_pay__section_b1g_m4s_b1c}

In the `TroubleTicketNotificationUtil` script include, you must add a method that constructs the required TMF-compliant payload for the new trouble ticket event and then return that payload.  
For examples of methods that create payloads for the base system trouble ticket events, refer to the following methods in the [TroubleTicketNotificationUtilOOB](https://servicenow-prod.fluidtopics.net/49rI6TtTOW4xEw2bFabuCQ#TroubleTicketNotifScopedAPI "The TroubleTicketNotificationUtilOOB script include provides methods used to define and generate the TMF-compliant payloads for trouble ticket notification events.") script include:

* [generateCreateTroubleTicketEventPaylaod()](https://servicenow-prod.fluidtopics.net/49rI6TtTOW4xEw2bFabuCQ#TTNUO-genCreateTTEvtPay_O_S_S "Constructs the TMF-compliant payload for the associated create trouble ticket for incident event type.")
* [generateCreateTroubleTicketEventPaylaodForCase()](https://servicenow-prod.fluidtopics.net/49rI6TtTOW4xEw2bFabuCQ#TTNUO-genCreateTTEvtPayCase_O_S_S "Constructs the TMF-compliant payload for the associated create trouble ticket for case event type.")
* [generateTroubleTicketAttributeChangePayload()](https://servicenow-prod.fluidtopics.net/49rI6TtTOW4xEw2bFabuCQ#TTNUO-genTTAttChgPay_O_S_S "Constructs the TMF-compliant payload for the trouble ticket attribute change event for incident event type.")
* [generateTroubleTicketStatusChangePayload()](https://servicenow-prod.fluidtopics.net/49rI6TtTOW4xEw2bFabuCQ#TTNUO-genTTStatChgPay_O_S_S "Constructs the TMF-compliant payload for the associated trouble ticket status change event for incident event type.")
{#prd_evt_not-dev_gd-gen_evt_pay__ul_urf_xfw_c1c}

## Add the event to the fetchEventHandlerAndCreateTMFEvent() switch/case logic {#prd_evt_not-dev_gd-gen_evt_pay__section_ifc_fps_b1c}

For the function that you created to be executed, you must add it in the `switch/case` logic within the fetchEventHandlerAndCreateTMFEvent() method of the EventProcessorUtil script include. The following code snippet shows the updates necessary to add the `ResolveTroubleTicketEventForIncident` event type to this method. For details on the fetchEventHandlerAndCreateTMFEvent() method, see [EventProcessorUtilOOB - fetchEventHandlerAndCreateTMFEvent(Object eventSnapshot, String eventType, String eventId)](https://servicenow-prod.fluidtopics.net/OxiAikQzYpYZMU65M1pfVQ#EPUO-FetEvHandCreatTMFEv_O_S_S "Converts the passed raw event object into a TMF-compliant event object by invoking a payload generator based on the event type.").

    fetchEventHandlerAndCreateTMFEvent: function(eventSnapshot, eventType, eventId) {
      var eventPayload;
      switch (eventType) {
        case Constants.EVENT_TYPES.TROUBLE_TICKET_STATUS_CHANGE:
          eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateTroubleTicketStatusChangePayload(eventSnapshot, eventType, eventId);
          break;

        case Constants.EVENT_TYPES.TROUBLE_TICKET_CREATE:
          eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateCreateTroubleTicketEventPaylaod(eventSnapshot, eventType, eventId);
          break;

        case Constants.EVENT_TYPES.TROUBLE_TICKET_ATTRIBUTE_CHANGE:
          eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateTroubleTicketAttributeChangePayload(eventSnapshot, eventType, eventId);
          break;

        case Constants.EVENT_TYPES.TROUBLE_TICKET_CREATE_FOR_CASE:
          eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateCreateTroubleTicketEventPaylaodForCase(eventSnapshot, eventType, eventId);
          break;

        // Add a new case statement for the ResolveTroubleTicketEventForIncident event type
        case 'ResolveTroubleTicketEventForIncident':
          eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateResolveTroubleTicketEventPyaload(eventSnapshot, eventType, eventId);
          break;

        default:
          this._logger.debug("Event with id " + eventId + " could not find the matching payload generator");
          eventPayload = null;
      }
      return eventPayload;
    },


