T
T
tatarrr952021-06-14 13:36:12
Google Apps Script
tatarrr95, 2021-06-14 13:36:12

How to catch an error in the onSubmit trigger and display it in the form?

Hello, I set up a trigger in google forms via google scripts so that the data from the form is sent by a post request. But sometimes on the server where I send the data, an error occurs. Now I can see these errors only by opening google scripts in the "Number of executions" tab.
How to catch the error and display it in the form itself so that I immediately understand that the data was not sent. and there was an error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Boev, 2021-06-14
@ProgrammerForever

As far as I know, in Google Forms it will not be possible to get a UI to show something


Note that in Google Forms, user-interface elements are visible only to an editor who opens the form to modify it, not to a user who opens the form to respond.

You can make a crutch and display error information at the end of the response, but it also does not work as intended, because information will appear only through the response, and not immediately:
function onSubmit(e) {
  try{
    // Что-то делаем
    throw "Тут происходит ошибка";    
  }catch(err){
    FormApp.getActiveForm().setConfirmationMessage(`Ошибка! ${err}`);
  };
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question