Question:
I have a web app to approve the responses of a form through an email.
In addition to that, I would like you to send me some emails that would be conditional on some of the responses on the form.
In order to simplify the code and give it a bit of order, I thought about:
- Do it in the same project, but in a different script file.
- In my main function (the one that fires via email) call the function that is in the other script file.
How can I do that?
I
DLIBRO = "1JN41GTgAl8Vl8gqGbBcyfaMs......."
IDHOJA = "Respuestas"
function doGet(e) {
var numeroAutorizacion = e.parameter['IdAprob']
var hoja = SpreadsheetApp.openById(IDLIBRO).getSheetByName(IDHOJA)
var aprobacion = hoja.getRange('I' + numeroAutorizacion).setValue("Si")
var hoy = hoja.getRange('J' + numeroAutorizacion).setValue(new Date())
correo()
}
Where mail is the other function.
Answer:
In the first version of the question it is mentioned that the shared code did not work. This is because the statements have not been separated with a semicolon.
Regarding whether it is possible to include several files in the same project and place different functions in this if possible. Calling a function that is in another file in the same project is very easy. Example:
Code.gs
function principal() {
//Llama la función llamada secundaria().
secundaria();
}
2.gs code
function secundaria() {
//Agrega al registro un mensaje de júbilo.
Logger.log('Me llamaron. ¡Viva!');
}
Considering the type of error, you might want to review a JavaScript course or the JavaScript guide published by the Mozilla Developers Network (MDN), since Google Apps Script is based on that language.
As for resources on Google Apps Script in Spanish, the following playlist from the Google Developers channel could be useful for you: Introduction to Google Apps Script