I developed a custom app and I’m using Data Method to get data from ticket and displayed the data in the app.
What I am facing now is when I clicked the Next button (as shown in the picture) to move to the next ticket, my app did not re-fetch/get new data from the next ticket but my app just displayed data from previous ticket.
Supposedly when Next button clicked, my app will loading and re-fetch new data from the next ticket.
Can someone help me what to add in my code to re-fetch new data from ticket when clicked the Next button?
I had checked with my local environment, and I didn’t see any issues with this, data-api is fetching the correct details when there is a navigation, possible can you please share the code snippet your are trying, we can help you further.
I think you should listen to “app.activated” event. As pointed out in the documentation:
To enable the app to refresh itself at the right time, the ticket page triggers an app.activated() event. Apps in the ticket_sidebar location are initially in a minimized state. When the agent expands the app for the first time on the page, the app receives the app.activated() event. If the agent navigates to another ticket and then expands the app (for the first time on that page), the app.activated() event is triggered again.
When the ticket page is loaded for the first time, the app.js file registers for the app.initialized() event. In the callback, it receives a client object and registers for the app.activated() event. The core logic of the app, which is to retrieve the ticket requester’s name and append it to a string, is contained in this callback.
I tested it here and clicking in “Next” button, always fire this event.