Uncaught TypeError: client.on is not a function at iframe.html:54

6 Comments

  • Joey
    Comment actions Permalink

    Hi Carlos-

    An app shouldn't stop working after an update occurs - can you give some more details & are you able to replicate this behavior in a simple test app? Is there anything else in the console that sheds light on this? It sounds like a timing issue. Is the the update to the ticket happening on the reload?

    0
  • Gary
    Comment actions Permalink

    I've run into this when redirecting the window location back to iframe.html from somewhere else without including the app_guid or origin as url parameters. The ZAFclient won't initialize without those

    0
  • Carlos Flores
    Comment actions Permalink

    Basically, it's a recreation of the private note app.  When an agent enters their note, it updates the ticket.  

    Update is applied, 

          
    <html>
      <head>
        <script
          type="text/javascript"
        ></script>
       <script>
          // Initialise the Zendesk JavaScript API client
          var client = ZAFClient.init();
          var id,
            ticket_id = 1;
     
          var form_data = new FormData();
          function sendNote() {
     
          ...

            var addNote = {
              url: url,
              data: json,
              type: "PUT",
              dataType: "json",
              contentType: "application/json"
            };

            client.request(addNote).then(function(data) {
              console.log(data);
            });
            document.getElementById("private_note").innerHTML =
              "Private note added";
          }
          function getCurrentUser() {
            return client.get("currentUser").then(function(data) {
              return data["currentUser"];
            });
          }

          function init() {
            getCurrentUser().then(function(currentUser) {});
          }
          client.on("app.registered", function() {
            client.get(["currentUser.id", "ticket.id"]).then(function(data) {
              id = data["currentUser.id"];
              ticket_id = data["ticket.id"];
            });
          });
        </script>
    0
  • Bryan - Community Manager
    Comment actions Permalink

    Hello Carlos. I'm circling back on this post -- did you get past this error?

    As Gary mentioned, if reloading the app (say through a window.location.reload() or setting window.location.href or submit operation) and the app_guid and origin query parameters that were originally passed in are not passed in again, the ZAFClient.init() call will fail. A ZAF app on reload without these parameters will return this error.

    0
  • Carlos Flores
    Comment actions Permalink

    Sadly, no.  

    I may revisit next year, when I have time to play with it

    0
  • Bryan - Community Manager
    Comment actions Permalink

    OK Carlos. When you do get a chance, check out that "resubmit without 'app_id' and 'origin' query parameters" angle. It looks like the app is being refreshed/reloaded by the app's own code and not re-passing these values along.

    0

Please sign in to leave a comment.

Powered by Zendesk