Hello,
I'm working on a Status.io integration and I'm having a bit of difficulty dealing with the ZAFClient in the context of a pop-out modal. My code can be found here:
https://github.com/sbarbett/status_io
When creating an incident, I have the app invoking a modal which contains a form with some fields that are necessary in the API request that gets sent to Status.io. However, I'm seeing some peculiar behavior. I had this working correctly before I tried putting the form inside a modal, by that I mean I was able to create an incident from the app. Now, when I try to submit the form from the modal, I'm getting an error in the console:
Uncaught TypeError: client.invoke is not a function
<anonymous> http://localhost:4567/0/assets/modal.js:4
<anonymous> http://localhost:4567/0/assets/modal.js:90
It's like it's looping back to the beginning of my modal.js script and the client object is no longer instantiated. I can see it instantiated, however, in the console when the app is initially loaded.
I am attempting to pass the parent client guid to the modal so I have access to the ticket and, to do so, I initially referred to this blog post to try and get it working: https://developerblog.zendesk.com/making-modals-work-in-zaf-v2-251b7c940e58




Taking a look at the Medium article and comparing it to your code, the only difference I notice is that, in your app, the modal instance is trying to register prior to the parent guid being passed to it. I see that you have
client.on('app.registered', init)in your modal.js file.In the Medium example the modal is being created at the same time that the ticket app client is registered. So that when instances.create is ran the modal client has already been registered. In your app though, a button is being used to trigger the modal creation.
Right now, we have the modal trying to register before the button click but it doesn't yet have the parentGuid from the sidebar app.
I suggest removing
client.on('app.registered', init)from the modal.js file.Move the createModal function to the modal.js file (wrapped around the init) so that you can ensure the modal init takes place prior passing the data and parentGuid.
Hope this helps!
Erica