{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":938,"path":"api-reference/server-api-reference/TroubleTicketNotifScopedAPI.md","title":"TroubleTicketNotificationUtilOOB - Scoped","bundle":null,"doc_type":null,"release":"australia","body":"\n# TroubleTicketNotificationUtilOOB- Scoped\n\nThe TroubleTicketNotificationUtilOOB script include provides methods used to define and generate the TMF-compliant payloads for trouble ticket notification events.\n\nOverride the methods in this script include to:\n\n-   Add/remove attributes to an existing trouble ticket event type.\n-   Define attributes for a new trouble ticket event type.\n\nFor additional information, see [Configure trouble ticket notifications using the Producer Event Notification Framework](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/developer-guides/prd_evt_not-dev_gd-cfg_trbl_tkt_not.md).\n\nThis script include runs within the `sn_ind_tsm_sdwan` namespace.\n\nThe calling user must have the ticket\\_integrator role.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## TroubleTicketNotificationUtilOOB - addAdditionalEventAttributes\\(Object tmfEventPayload\\)\n\nAdds custom event header attributes to the passed TMF trouble ticket event payload. The attributes added by this method are added to the event-level header for all trouble ticket events.\n\n|Name|Type|Description|\n|----|----|-----------|\n|tmfEventPayload|Object|TMF-compliant trouble ticket event payload. For details on the format of this event payload, see the [TMF621 Trouble Ticket Management API REST Specification v5.0.0](https://www.tmforum.org/resources/standard/tmf621-trouble-ticket-management-api-rest-specification-v5-0-0/) and the [TMF688 Event Management API User Guide v4.0.0](https://www.tmforum.org/resources/standard/tmf688-event-management-api-user-guide-v4-0-0/).|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following code example shows how to call this method.\n\n```\nconstructTMFEvent: function(eventId) {\n  var troubleTicketEvent = {};\n  if (gs.nil(eventId)) {\n    troubleTicketEvent.eventId = gs.generateGUID();\n  } else {\n    troubleTicketEvent.eventId = eventId;\n  }\n  troubleTicketEvent['@type'] = Constants.EVENT_TYPE_TROUBLE_TICKET;\n  this.addAdditionalEventAttributes(troubleTicketEvent);\n  return troubleTicketEvent;\n},\n```\n\n## TroubleTicketNotificationUtilOOB - constructTMFEvent\\(String eventId\\)\n\nGenerates the TMF688-compliant header attributes in the event section of the payload. These attributes are consistent across all event payloads.\n\nIn the default implementation, this method adds the **eventId** and the **@type** header attributes.\n\nThis method calls the helper method [addAdditionalEventAttributes\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/TroubleTicketNotifScopedAPI.md). In this method you can add other header attributes to the event payload. For details, see [Modify a trouble ticket event payload](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/developer-guides/prd_evt_not-dev_gd-mod-evt-pay.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|eventId|String|Unique identifier of the associated event. This can be any unique value. In the default implementation, if you don't pass the event ID, the value is set to a system generated GUID.|\n\n|Type|Description|\n|----|-----------|\n|Object|TMF payload with the event-level attributes set. For details on the format of this event payload, see the[TMF688 Event Management API User Guide v4.0.0](https://www.tmforum.org/resources/standard/tmf688-event-management-api-user-guide-v4-0-0/).|\n\nThe following code example shows how to call this method to construct the event header attributes when generating a trouble ticket attribute change payload.\n\n```\ngenerateTroubleTicketAttributeChangePayload: function(incidentGr, eventType, eventId) {\n  var tmfEventPayload = this.constructTMFEvent(eventId);\n  tmfEventPayload.eventType = eventType;\n  tmfEventPayload.event = this.addAttributeChangeTroubleTicketAttributes(incidentGr);\n\n  return tmfEventPayload;\n},\n```\n\n## TroubleTicketNotificationUtilOOB - generateCreateTroubleTicketEventPaylaod\\(Object incidentGr, String eventType, String eventId\\)\n\nConstructs the TMF-compliant payload for the associated create trouble ticket for incident event type.\n\nThis method is executed when the associated event type is `TROUBLE_TICKET_CREATE: \"TroubleTicketCreateEvent\"`. This method calls two helper methods:\n\n-   [constructTMFEvent\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/TroubleTicketNotifScopedAPI.md): Adds the event header attributes \\(TMF688\\) to the payload.\n-   addCreateTroubleTicketAttributes\\(\\): Override this method to add trouble ticket attributes \\(TMF621\\), both mandatory and optional, to the payload. This method is just a stub in the default implementation.\n\nYou can override these helper methods in the `TroubleTicketNotificationUtil` script include to configure both event header and trouble ticket attributes in the TMF-compliant payload.\n\n<table id=\"table_i5j_xcx_c1c\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nincidentGr\n\n</td><td>\n\nObject\n\n</td><td id=\"TTNUO-incidentGr-entry\">\n\nJSON formatted glide record that caused the trouble ticket event to be generated. Use the information in this glide record to construct the TMF621-compliant trouble ticket event payload.\n\n</td></tr><tr><td>\n\neventType\n\n</td><td>\n\nString\n\n</td><td>\n\nUnique identifier of the associated trouble ticket event type. For the default implementation of this method, this should always be\n\n `\"TroubleTicketCreateEvent\"`.For a list of all base trouble ticket event types, refer to *Constants.EVENT\\_TYPES* in the `sn_api_notif_mgmt.Constants` script include file.\n\n</td></tr><tr><td>\n\neventId\n\n</td><td>\n\nString\n\n</td><td id=\"TTNUO-eventId-entry\">\n\nUnique identifier of the associated event.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|Object|TMF-compliant trouble ticket event payload. For details on the format of this event payload, see the [TMF621 Trouble Ticket Management API REST Specification v5.0.0](https://www.tmforum.org/resources/standard/tmf621-trouble-ticket-management-api-rest-specification-v5-0-0/) and the [TMF688 Event Management API User Guide v4.0.0](https://www.tmforum.org/resources/standard/tmf688-event-management-api-user-guide-v4-0-0/).|\n\nThe following code example shows how to call this method.\n\n```\nfetchEventHandlerAndCreateTMFEvent: function(eventSnapshot, eventType, eventId) {\n  var eventPayload;\n  switch (eventType) {\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_STATUS_CHANGE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateTroubleTicketStatusChangePayload(eventSnapshot, eventType, eventId);\n      break;\n\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_CREATE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateCreateTroubleTicketEventPaylaod(eventSnapshot, eventType, eventId);\n      break;\n\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_ATTRIBUTE_CHANGE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateTroubleTicketAttributeChangePayload(eventSnapshot, eventType, eventId);\n      break;\n\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_CREATE_FOR_CASE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateCreateTroubleTicketEventPaylaodForCase(eventSnapshot, eventType, eventId);\n      break;\n\n    default:\n      this._logger.debug(\"Event with id \" + eventId + \" could not find the matching payload generator\");\n      eventPayload = null;\n  }\nreturn eventPayload;\n},\n```\n\n## TroubleTicketNotificationUtilOOB - generateCreateTroubleTicketEventPaylaodForCase\\(Object incidentGr, String eventType, String eventId\\)\n\nConstructs the TMF-compliant payload for the associated create trouble ticket for case event type.\n\nThis method is executed when the associated event type is `TROUBLE_TICKET_CREATE_FOR_CASE: \"TroubleTicketCreateEventForCase\"`. This method calls two helper methods:\n\n-   [constructTMFEvent\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/TroubleTicketNotifScopedAPI.md): Adds the event attributes \\(TMF688\\) to the payload.\n-   addCreateTroubleTicketAttributesForCase\\(\\): Override this method to add trouble ticket attributes \\(TMF621\\), both mandatory and optional, to the payload. This method is just a stub in the default implementation.\n\nYou can override these helper methods in the `TroubleTicketNotificationUtil` script include to configure both event header and trouble ticket attributes in the TMF-compliant payload.\n\n<table id=\"table_i5j_xcx_c1c\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nincidentGr\n\n</td><td>\n\nObject\n\n</td><td id=\"TTNUO-incidentGr-entry\">\n\nJSON formatted glide record that caused the trouble ticket event to be generated. Use the information in this glide record to construct the TMF621-compliant trouble ticket event payload.\n\n</td></tr><tr><td>\n\neventType\n\n</td><td>\n\nString\n\n</td><td>\n\nUnique identifier of the associated trouble ticket event type. For the default implementation of this method, this should always be\n\n `\"TroubleTicketCreateEvent\"`.For a list of all base trouble ticket event types, refer to *Constants.EVENT\\_TYPES* in the `sn_api_notif_mgmt.Constants` script include file.\n\n</td></tr><tr><td>\n\neventId\n\n</td><td>\n\nString\n\n</td><td id=\"TTNUO-eventId-entry\">\n\nUnique identifier of the associated event.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|Object|TMF-compliant trouble ticket event payload. For details on the format of this event payload, see the [TMF621 Trouble Ticket Management API REST Specification v5.0.0](https://www.tmforum.org/resources/standard/tmf621-trouble-ticket-management-api-rest-specification-v5-0-0/) and the [TMF688 Event Management API User Guide v4.0.0](https://www.tmforum.org/resources/standard/tmf688-event-management-api-user-guide-v4-0-0/).|\n\nThe following code example shows how to call this method.\n\n```\nfetchEventHandlerAndCreateTMFEvent: function(eventSnapshot, eventType, eventId) {\n  var eventPayload;\n  switch (eventType) {\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_STATUS_CHANGE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateTroubleTicketStatusChangePayload(eventSnapshot, eventType, eventId);\n      break;\n\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_CREATE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateCreateTroubleTicketEventPaylaod(eventSnapshot, eventType, eventId);\n      break;\n\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_ATTRIBUTE_CHANGE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateTroubleTicketAttributeChangePayload(eventSnapshot, eventType, eventId);\n      break;\n\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_CREATE_FOR_CASE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateCreateTroubleTicketEventPaylaodForCase(eventSnapshot, eventType, eventId);\n      break;\n\n    default:\n      this._logger.debug(\"Event with id \" + eventId + \" could not find the matching payload generator\");\n      eventPayload = null;\n  }\nreturn eventPayload;\n},\n```\n\n## TroubleTicketNotificationUtilOOB - generateTroubleTicketAttributeChangePayload\\(Object incidentGr, String eventType, String eventId\\)\n\nConstructs the TMF-compliant payload for the trouble ticket attribute change event for incident event type.\n\nThis method is executed when the associated event type is `TROUBLE_TICKET_ATTRIBUTE_CHANGE: \"TroubleTicketAttributeChangeEvent\"`. This method calls two helper methods:\n\n-   [constructTMFEvent\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/TroubleTicketNotifScopedAPI.md): Adds the event attributes \\(TMF688\\) to the payload.\n-   addAttributeChangeTroubleTicketAttributes\\(\\): Override this method to add trouble ticket attributes \\(TMF621\\), both mandatory and optional, to the payload. This method is just a stub in the default implementation.\n\nYou can override these helper methods in the `TroubleTicketNotificationUtil` script include to configure both event header and trouble ticket attributes in the TMF-compliant payload.\n\n<table id=\"table_i5j_xcx_c1c\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nincidentGr\n\n</td><td>\n\nObject\n\n</td><td id=\"TTNUO-incidentGr-entry\">\n\nJSON formatted glide record that caused the trouble ticket event to be generated. Use the information in this glide record to construct the TMF621-compliant trouble ticket event payload.\n\n</td></tr><tr><td>\n\neventType\n\n</td><td>\n\nString\n\n</td><td>\n\nUnique identifier of the associated trouble ticket event type. For the default implementation of this method, this should always be\n\n `\"TroubleTicketCreateEvent\"`.For a list of all base trouble ticket event types, refer to *Constants.EVENT\\_TYPES* in the `sn_api_notif_mgmt.Constants` script include file.\n\n</td></tr><tr><td>\n\neventId\n\n</td><td>\n\nString\n\n</td><td id=\"TTNUO-eventId-entry\">\n\nUnique identifier of the associated event.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|Object|TMF-compliant trouble ticket event payload. For details on the format of this event payload, see the [TMF621 Trouble Ticket Management API REST Specification v5.0.0](https://www.tmforum.org/resources/standard/tmf621-trouble-ticket-management-api-rest-specification-v5-0-0/) and the [TMF688 Event Management API User Guide v4.0.0](https://www.tmforum.org/resources/standard/tmf688-event-management-api-user-guide-v4-0-0/).|\n\nThe following code example shows how to call this method.\n\n```\nfetchEventHandlerAndCreateTMFEvent: function(eventSnapshot, eventType, eventId) {\n  var eventPayload;\n  switch (eventType) {\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_STATUS_CHANGE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateTroubleTicketStatusChangePayload(eventSnapshot, eventType, eventId);\n      break;\n\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_CREATE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateCreateTroubleTicketEventPaylaod(eventSnapshot, eventType, eventId);\n      break;\n\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_ATTRIBUTE_CHANGE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateTroubleTicketAttributeChangePayload(eventSnapshot, eventType, eventId);\n      break;\n\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_CREATE_FOR_CASE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateCreateTroubleTicketEventPaylaodForCase(eventSnapshot, eventType, eventId);\n      break;\n\n    default:\n      this._logger.debug(\"Event with id \" + eventId + \" could not find the matching payload generator\");\n      eventPayload = null;\n  }\nreturn eventPayload;\n},\n```\n\n## TroubleTicketNotificationUtilOOB - generateTroubleTicketStatusChangePayload\\(Object incidentGr, String eventType, String eventId\\)\n\nConstructs the TMF-compliant payload for the associated trouble ticket status change event for incident event type.\n\nThis method is executed when the associated event type is `TROUBLE_TICKET_STATUS_CHANGE: \"TroubleTicketStatusChangeEvent\"`. This method calls two helper methods:\n\n-   [constructTMFEvent\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/TroubleTicketNotifScopedAPI.md): Adds the event attributes \\(TMF688\\) to the payload.\n-   addStatusChangeTroubleTicketAttributes\\(\\): Override this method to add trouble ticket attributes \\(TMF621\\), both mandatory and optional, to the payload. This method is just a stub in the default implementation.\n\nYou can override these helper methods in the `TroubleTicketNotificationUtil` script include to configure both event header and trouble ticket attributes in the TMF-compliant payload.\n\n<table id=\"table_i5j_xcx_c1c\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nincidentGr\n\n</td><td>\n\nObject\n\n</td><td id=\"TTNUO-incidentGr-entry\">\n\nJSON formatted glide record that caused the trouble ticket event to be generated. Use the information in this glide record to construct the TMF621-compliant trouble ticket event payload.\n\n</td></tr><tr><td>\n\neventType\n\n</td><td>\n\nString\n\n</td><td>\n\nUnique identifier of the associated trouble ticket event type. For the default implementation of this method, this should always be\n\n `\"TroubleTicketCreateEvent\"`.For a list of all base trouble ticket event types, refer to *Constants.EVENT\\_TYPES* in the `sn_api_notif_mgmt.Constants` script include file.\n\n</td></tr><tr><td>\n\neventId\n\n</td><td>\n\nString\n\n</td><td id=\"TTNUO-eventId-entry\">\n\nUnique identifier of the associated event.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|Object|TMF-compliant trouble ticket event payload. For details on the format of this event payload, see the [TMF621 Trouble Ticket Management API REST Specification v5.0.0](https://www.tmforum.org/resources/standard/tmf621-trouble-ticket-management-api-rest-specification-v5-0-0/) and the [TMF688 Event Management API User Guide v4.0.0](https://www.tmforum.org/resources/standard/tmf688-event-management-api-user-guide-v4-0-0/).|\n\nThe following code example shows how to call this method.\n\n```\nfetchEventHandlerAndCreateTMFEvent: function(eventSnapshot, eventType, eventId) {\n  var eventPayload;\n  switch (eventType) {\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_STATUS_CHANGE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateTroubleTicketStatusChangePayload(eventSnapshot, eventType, eventId);\n      break;\n\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_CREATE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateCreateTroubleTicketEventPaylaod(eventSnapshot, eventType, eventId);\n      break;\n\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_ATTRIBUTE_CHANGE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateTroubleTicketAttributeChangePayload(eventSnapshot, eventType, eventId);\n      break;\n\n    case Constants.EVENT_TYPES.TROUBLE_TICKET_CREATE_FOR_CASE:\n      eventPayload = new sn_ind_tsm_sdwan.TroubleTicketNotificationUtil().generateCreateTroubleTicketEventPaylaodForCase(eventSnapshot, eventType, eventId);\n      break;\n\n    default:\n      this._logger.debug(\"Event with id \" + eventId + \" could not find the matching payload generator\");\n      eventPayload = null;\n  }\nreturn eventPayload;\n},\n```\n\n"}}