I have search for hours and cant find a solution to this. I have some appscript code that creates a menu and open a modal in google docs:
function showDialog() {
let ui = DocumentApp.getUi();
let html = HtmlService.createHtmlOutputFromFile("dialog");
ui.showModalDialog(html, "dtest");
}
function processForm() {
console.log("test123123123");
}
This works, the modal opens.
In the modal i want to submit a form. For now im just calling a test function when submitting that console.logs to the cloud logger.
<script>
// Prevent form from submitting
function preventFormSubmit() {
var forms = document.querySelectorAll("form");
for (var i = 0; i < forms.length; i++) {
forms[i].addEventListener("submit", function (event) {
event.preventDefault();
});
}
}
window.addEventListener("load", preventFormSubmit);
google.script.run.processForm();
</script>
The problem here is that the function processForm() is not triggered.
BUT when i use a doGet() and deploy it as a webapp it works.
How can i get it to work in google docs also? I have tried following the documentation..but i cant get it to work.
Thanks in advance for any help with this.
processForm()
? Maybe you can implement a log before ` google.script.run.processForm();` - to see if your execution get that far? – ziganotschka