ZAF Client Context gives WRONG Active Ticket ID when Agent changes between Multiple Ticket Tabs open in their Workspace
RespondidaZendesk Issue When Agent has multiple Ticket-tabs open in the Agent Workspace ( in a single Browser-Tab) inside their Zendesk account, and switching between multiple ticket tabs - the Zendesk Currently - Active Ticket-Id is wrong inside the ZAFClient Context for ticket_Sidebar Iframe Application
PROBLEM DESCRIPTION:
When zendesk agent logs into their Zendesk account, and opens their first ticket, Ticket-1, it registers and loads our Sidebar application in Ticket-1 sidebar - at that moment, the ZAFClient Context has the correct current ticket ID, 'Ticket-1'..
Then Agent opens another ticket tab for Ticket-2 - at this point, since it has again reloaded Sidebar application in ticket sidebar, it SEEMs to correctly UPDATE the ZAFClient Context with the newly opened ticket's ID, i.e. 'Ticket-2'.
The Agent again opens a third Ticket Tab for Ticket-3. Now, agent has 3 ticket tabs open in her Agent-Workspace, with the Ticket-3_TAB 'ACTIVE' (selected) while the Ticket-1_TAB and the Ticket-2_TAB are both 'INACTIVE' (not selected).
Now when agent simply switches between the tabs (i.e. clicks on Ticket-1_TAB to make it the current 'ACTIVE' ticket tab), it DOESN'T SEEM TO UPDATE ZAFClient Context with the correct Ticket ID, i.e. it still shows 'Ticket-3' instead of 'Ticket-1'.
In other words, when multiple Ticket Tabs are ALREADY Open, and the Agent switches between the Ticket Tabs, the ZAF Client Context does not seem to be update with the CURRENTLY ACTIVE TICKET-ID. AT this point it is not clear if the ZAFClient Context will have either STALE ticket Id OR, it might RANDOMLY pick another ticket ID from any of the open Ticket Tabs.
This creates a significant problem for any Sidebar Application trying to service the SPECIFIC TICKET that Agent has open and is trying take any updates.
DESIRED SOLUTION/BEHAVIOR:
What we want is that the ZAFClient Context ALWAYS has the correct Ticket-ID of the Currently ACTIVE Ticket-Tab in the Agent's Workspace.
ATTEMPTED FIX - BUT, DOES NOT WORK
We actually tried using "app.activated" event as shown in the code snippet below, to look for active tab's ticket information from the context, but it picks up wrong ticket id when the Agent switches the Active Ticket Tab. So it gives wrong Ticket-ID without showing any Error message/indications.
HERE IS THE CODE WE HAVE TRIED
var zafClient = ZAFClient.init();
zafClient.on('app.registered', e => {
zafClient.on("app.activated", function(context) {
console.log(context);
console.log(context.ticketId);
sessionStorage.setItem("zdTicket",context.ticketId);
}) });
===== >> COULD Zendesk Support Team PLEASE:
1) Share a working example of how to get the correct Ticket-ID when the Agent switches/jumps between already open Ticket Tabs in their workspace?
2) Are we using the wrong event or error in the code? Please help us resolve this at your earliest convenience.
Thanks a lot. :-)
-
Hey there,
It looks like you're just pulling the data provided by the app.activated event. Which doesn't actually include the context you're looking for. Additionally it wouldn't fire on the initial load of the tab as you're basing it off the app.registered event layered with app.activated (which doesn't happen on initial load).
The below code snippet will fire a zafClient.context call on the app.registration and app.activated event separately to pull the necessary info on the different events.
var zafClient = ZAFClient.init();
zafClient.on("app.registered", e => {
zafClient.context().then(function (context) {
console.log(`DEBUG ${zafClient._context["location"]} app.registered`, context.ticketId);
})
zafClient.on("app.activated", function () {
zafClient.context().then(function (context) {
console.log(`DEBUG ${zafClient._context["location"]} app.activated`, context.ticketId);
})
})
});
Hope this helps
-
Hi Eric Nelson,
Thanks for your help. We tried implementing your approach in our App, but we are not able to make it work on our end.
Would you please check this out for some more details?
We are not seeing where the mistake is - please help us resolve this issue.
Thanks a lot. :-)
-
Hey there,
After taking a look at the code you provided, I'm assuming you're setting the sessionStorage in the registerApp() function. Though it looks like the only thing you're doing with the app.activated is the console.log that I provided in my example. If you're wanting the sessionStorage to update as you switch between ticket tabs, you'll need to be setting sessionStorage both in the register and activate events. The below gif showcases this expected functionality in combination with the code snippet below.
<script>
var zafClient = ZAFClient.init();
zafClient.on("app.registered", function () {
zafClient.context().then(function (context) {
sessionStorage.setItem("zdTicket", context.ticketId)
})
zafClient.on("app.activated", function () {
zafClient.context().then(function (context) {
sessionStorage.setItem("zdTicket", context.ticketId)
})
})
});
</script> -
HI Eric,
We added some more clarification and updates to my problem description slides.
Hopefully this will help understand our issue better. Thanks a lot for your help. Looking forward to hearing from you.
-
Hey there,
I've adjusted my application to be server side as to match your use case and I am still unable to replicate your issue. I'm going to move this into a ticket so that we can set up a call to go over your issue more in depth.
Thanks!
Iniciar sesión para dejar un comentario.
5 Comentarios