Listen ticket update event in full page app

Hello, I’m Juyeong.

Is there any way to listen ticket update event in full page app?
I coding like below, but can’t listen ticket update.

document.onreadystatechange = function () {
  if (document.readyState === 'interactive') renderApp();

function renderApp() {
    var onInit = app.initialized();
    onInit.then(getClient).catch(handleErr);
    function getClient(_client) {
      window.client = _client;
      client.events.on('app.activated', onAppActivate);
    }
  }
};

function ticketUpdate(event){
  console.log(event.helper.getData());
}

Hi @Juyeong_Lee,

It would also be helpful if you could describe what use case you are trying to solve broadly?

One way app can listen to update events is by ticket.propertiesUpdated.

document.onreadystatechange = function init() {
  if (document.readyState == 'interactive') renderApp();

  function renderApp() {
    var onInit = app.initialized();
    onInit.then(getClient).catch(console.error);
  }
};

function getClient(_client) {
  window.client = _client;
  client.events.on('app.activated', onAppActivate);

  function onAppActivate() {
    client.events.on('ticket.propertiesUpdated', onTicketPropUpdate, { intercept: false });

    function onTicketPropUpdate(event) {
      // your business logic
      
      // To allow ticket property to be updated
      event.helper.done();

      // to prevent: event.helper.fail('error message') and {intercept: true} at the call site.
    }
  }
}

Hi, @Saif

Thank you for your reply.

Do those codes work on the full-page app?

You need to develop a custom calendar page with a new desk ticket.
If the agent creates a new desktop ticket, it appears immediately on the Custom Calendar App page.
And another freshdesk tickets also show custom calendar app page.

And “event.helper.done();” is occurred warning message when fdk pack.
Expected rejection to be handled.

Hi, @Saif

“Expected rejection to be handled.” message is not issue.

They should ideally work.

Here is a sample app that demonstrates the same,

https://github.com/freshworks/marketplace-sample-apps/tree/master/Freshworks-Samples/App-Development-Features/Basic-Features/events_method/intercepting_events_app

But for full page app, the event listener is registered after user clicks and opens full page app as opposed to ticket_background placeholder of above sample app.

In case if you want listener to be registered before user clicks on full page app icon and open the app, you will have to move ticket.propertiesUpdated listener inside of app.initialized() callback.

Thank you for help.

I don’t need information about the way listen ticket update event in full page app.
I thought it was difficult, so I had an internal discussion, and I decided to bring the information with api without listen ticket update event.