Error: Time has run out while waiting for the user's response


Trying to send several Mails triggers this error. How can I start fixing the error that says: "Time has run out while waiting for the user's response". Sometimes it works and sometimes the bug does not come out.

This is my code:

function onEdit(evt){
  var range=evt.range;
  var ui = SpreadsheetApp.getUi();

  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var worksheet   = spreadsheet.getSheetByName("Respuestas de formulario 1");
  var texto=worksheet.getRange( range.getRow(),range.getColumn()).getValue();//numero gestores para iniciar bucle//

  //si es fila 26//

  //averiguamos cuantos admins hay
  var style = get_status(texto);
  worksheet.getRange( range.getRow(),range.getColumn()).setValue(texto).setBackgroundColor(style[0].color);

  var admins=list_admins(worksheet.getRange('E'+ range.getRow()).getValue());
  var nnotificados=admins.length; 
   var response = ui.alert('Desea notificar al remitente vía mail', ui.ButtonSet.YES_NO);

    // Process the user's response.
    if (response == ui.Button.YES) {
      Logger.log('Enviaron a:');
      for (var i=0;i<nnotificados;i++){
       // ui.alert(template_change_status(admins[i],range,worksheet,style[0].color));
        //si el asunto es finzalizada no lio
        var asunto="";

        if("Finalizado Cargue al LMS" == worksheet.getRange('Z'+ range.getRow()).getValue()  ){
          asunto=worksheet.getRange('Z'+ range.getRow()).getValue();
          asunto=worksheet.getRange('Z'+ range.getRow()).getValue()+" N: "+worksheet.getRange('AC'+ range.getRow()).getValue()+ " Ficha: "+worksheet.getRange('D'+ range.getRow()).getValue()+ " Ticket: "+worksheet.getRange('X'+ range.getRow()).getValue();


asked by Edilson Laverde Molina 16.05.2018 в 05:24

1 answer


The error means that there is a user interface element that is waiting for an answer, but this happens synchronously, so the execution time is still running.

If you require that the wait has no time limit, then you must change the logic of your script, for example, instead of using a simple trigger when editing (onEdit) it uses an interface element that makes the sending when it indicates it the user.

answered by 16.05.2018 / 19:14