Recent searches
No recent searches
Using modal to verify input from user when saving
Posted Oct 31, 2023
I'm working on using a modal window to pop up when saving, that waits for the agents confirmation before continuing, but can't find a way to pause the save process and resume it on command.
I've got the modal down, and communicating back to the parent sidebar, but since the ticket submit button (client.on(ticket.save)) triggers the modal, I can't trigger anything to go ahead with the save process?
sidebar events: https://developer.zendesk.com/api-reference/apps/apps-support-api/ticket_sidebar/#ticket-save-hook-events
In short: (the bold below is the issue)
- on ticket update/save
- open modal window and ask user to confirm value X
- if ok then continues the save process
- if cancel then notify that confirmation is needed. Do not save
2
6
6 comments
Greg Katechis
Hi Daniel! Our team actually built an example app that is close to this situation that you can look at in its entirety here. The specific stuff that you'll probably find useful is going to start on line 90, which highlights how we pass data from the modal to the sidebar. In your situation, you'll want to start with an async function on save that remains open until the user presses ok or cancel. For the save and cancel actions you'll just use the reference docs in the link that you provided and you'll be good to go!
0
Daniel Wennerdahl
Hi, Greg Katechis
Thank you for the example. However I cant get this to work since I'm within the client.on('ticket.save'). The app has functionality that cant be loaded in the modal window so can't use the same JS file there.
Even if the listeners could be registered, there needs to be a promise to "pause" the save process, that in turn needs to be resolved to proceed.
I cant find anything in the documentation that covers this more then the events them self's. Maybe I'm just bad at searching :D
0
Corentin BERTEAU
Hi Daniel Wennerdahl
I'm trying to do the same thing, but from the moment my function is asynchronous,
client.on('ticket.save', async function () {... return false;}
doesn't work.The only way I've found, and it's very ugly, is to call a nonexistent variable to block the sending by creating an error... If I find a solution or if I manage to make it work, I'll keep you informed.
It's possible anyway; the 'cancel submit ticket' application does exactly what we're trying to reproduce.
----
* update *
My bad, to cancel async function : return Promise.reject(false);
I will review my code and share my approach here asap.
0
Daniel Wennerdahl
Hi Corentin BERTEAU
I found a solution for this, it not pretty, but it works =)
I have an async method in the client.on event that runs a while loop, and every sec checks for status variabels set from the modal through custom triggers.
This post show how these custom triggers can be created:
In the modal window (modal.js)
0
Corentin BERTEAU
Hi,
Thanks for sharing this, my way to do this below but can't find a solution to update modal.html with some ticket info.
0
Daniel Wennerdahl
Hi Corentin BERTEAU
You can send parameter along with the invoke of the modal, then read them in the modal/iframe.
Important here is also that the jsonObject must be uri encoded.
example:
0