I need to fetch change logs on the ticket update event for custom fields but in the documentation, it is clearly mentioned as a below restriction
The following changes will NOT trigger the onTicketUpdate event.
Hope you are well
This is one of the restrictions we have when working with Onticketupdate events, before answering your question,
I’d like to clarify that changelog is not available in the event payload for both custom and default fields in the serverless app. the event payload just gives the current ticket payload related to the event and no historic data.
In the frontend app, using the ticket.propertiesUpdated event, the difference in value can be obtained from the previous and the current value for only the default fields(this will not give a historical changelog, but only a difference between the current and the previous values). and in the case of the custom field, a boolean whether the custom field is changed or not can be obtained from the ticket.propertiesUpdated event.
Setting the restrictions aside, there are few workarounds we can try to overcome this problem,
Approach 1 :
Use the ticket data method, fetch the details of the current ticket on the app’s initial load(app.activated event) and save it in either browser’s local storage or the developer platform’s data storage.
make the changes in the property, including the custom field, and click update, this will trigger the ticket.propertiesUpdated event, inside the handler that handles the event, Check if the custom field is updated, by checking the presence of
isCustomFieldsChanged is present, use the data method again, to get the current value of the ticket.
compare the custom field between both the saved value during the app load and the current value, send the difference, or the whole value to the backend/serverless app using an SMI call, and carry on with the rest of the execution in the serverless app.
make the changes in the property, including the custom field, and click update, this will trigger the ticket.propertiesUpdated event, inside the handler that handles the event Check if the custom field is updated, by checking the presence of
isCustomFieldsChanged is present, use the data method to get the current ticket ID and send only the ticket ID to the serverless app.
From the serverless app, using the ticket ID that you received from the frontend app through SMI, make an API call to get all the ticket fields including the changes in the custom field.
Hope this helps!
Thanks for your help. I hope this will work for me.