ZAF Client Context gives WRONG Active Ticket ID when Agent changes between Multiple Ticket Tabs open in their Workspace

답변함

5 댓글

  • Eric Nelson
    Zendesk Developer Advocacy
    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
    0
  • DZSS

    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. :-)

     

    0
  • Eric Nelson
    Zendesk Developer Advocacy
    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>
    0
  • DZSS

    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.

    0
  • Eric Nelson
    Zendesk Developer Advocacy
    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! 
    0

댓글을 남기려면 로그인하세요.

Zendesk 제공