Java - Ayuda con mi codigo desarrolado en apps script

 
Vista:
sin imagen de perfil

Ayuda con mi codigo desarrolado en apps script

Publicado por sebastian (1 intervención) el 20/04/2023 23:16:28
Este proyecto esta desarrollado con el fin de anunciar la semana de google donde se va explicar la ofimatica de google, mi error es que a la hora de usar las listas desplegables me trae toda la informacion que tengo en la google sheet y no me trae lo que busco en concreto, tambien tengo un fallo con los disparadores de los filtros que solo se me activa uno en concreto el de tipo.
si me pueden ayudar les agradeceria muchisimo.


Este es el codigo .gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// funcion para enlazar html con appscript en la constante html se trae el index
function doGet(){
  const html = HtmlService.createTemplateFromFile("index").evaluate();
  return html;
}
//funcion para buscar registros segun sea la tematica que se haya escogido en la lista desplegable
function BuscarRegistros(frente=""){
  let registrosBuscados =[];
 
  const SS = SpreadsheetApp.getActiveSpreadsheet();
  const sheetEventos = SS.getSheetByName("Datos1");
  const eventos = sheetEventos.getDataRange().getDisplayValues();
 
 
  eventos.forEach(evento=>{
    if(evento[1] === frente){
      registrosBuscados.push(evento);
    }
  })
  return registrosTBuscados;
}
 
function BuscarIdioma(tipoidioma=""){
  let registrosBuscados =[];
 
  const SS=SpreadsheetApp.getActiveSpreadsheet();
  const sheetEventos = SS.getSheetByName("Datos1");
  const eventos = sheetEventos.getDataRange().getDisplayValues();
 
  eventos.forEach(evento=>{
    if(evento[8]=== tipoidioma){
      registrosBuscados.push(evento);
    }
  })
  return registrosTBuscados;
}
 
//funcion para buscar registros segun sea el tipo que se haya escogido en la lista desplegable
 
function BuscarRegistros(tipoevento=""){
  let registrosTBuscados =[];
 
  const SS=SpreadsheetApp.getActiveSpreadsheet();
  const sheetEventos = SS.getSheetByName("Datos1");
  const eventos = sheetEventos.getDataRange().getDisplayValues();
 
 
  eventos.forEach(evento=>{
    if(evento[3]=== tipoevento){
      registrosTBuscados.push(evento);
    }
  })
  return registrosTBuscados;
 
}


Este es el index
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet"               integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
  </head>
  <body style="background-color: #ffffff;">
    <!---------------------------------------TITULO DEl GOOGLE WEEK--------------------------------------------------->
   <head>
<!----
     <img src="http://drive.google.com/uc?export=view&id=1Th8TLpsimYjUVz-PvtdmAqhmX0jVkHmF" class="mx-auto d-block"alt="Analitica"style="width: 1340px;1080px; height:480px">
     -->
 
 
    <title>Titulo</title>
 
 
    <style>
      .red {
        color: #EA4335;
      }
      .green {
        color: #34A853;
      }
      .blue {
        color: #4282F4;
      }
      .yellow{
        color: #FBBC04;
      }
      .gray{
        color: #5F6383;
      }
      h1 {
        text-align: center;
        font-size: 100px;
      }
      H3 {
        text-align: center;
        font-size: 50px;
      }
 
 
    </style>
  </head>
  <body>
    <h1>
      <span class="blue">G</span>
      <span class="red">o</span>
      <span class="yellow">o</span>
      <span class="blue">g</span>
      <span class="green">l</span>
      <span class="red">e</span>
      <span class="gray">W</span>
      <span class="gray">e</span>
      <span class="gray">e</span>
      <span class="gray">k</span>
    </h1>
 
  </body>
    <!------------------------------------------------------Carrusel------------------------------------------------------>
    <div id="carouselInterval" class="carousel slide" data-bs-ride="carousel">
        <div class="carousel-indicators">
            <button type="button"data-bs-target="#carouselInterval" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
            <button type="button" data-bs-target="#carouselInterval" data-bs-slide-to="1" aria-label="Slide 2"></button>
            <button type="button" data-bs-target="#carouselInterval" data-bs-slide-to="2" aria-label="Slide 3"></button>
            <button type="button" data-bs-target="#carouselInterval" data-bs-slide-to="3" aria-label="Slide 4"></button>
            <button type="button" data-bs-target="#carouselInterval" data-bs-slide-to="4" aria-label="Slide 5"></button>
            <button type="button" data-bs-target="#carouselInterval" data-bs-slide-to="5" aria-label="Slide 6"></button>
            <button type="button" data-bs-target="#carouselInterval" data-bs-slide-to="6" aria-label="Slide 7"></button>
            <button type="button" data-bs-target="#carouselInterval" data-bs-slide-to="7" aria-label="Slide 8"></button>
          </div>
        <div class="carousel-inner">
          <div class="carousel-item active" data-bs-interval="4500">
            <img src="http://drive.google.com/uc?export=view&id=1Th8TLpsimYjUVz-PvtdmAqhmX0jVkHmF" class="mx-auto d-block"alt="Analitica"style="width: 1340px;1080px; height:480px">
          </div>
          <div class="carousel-item" data-bs-interval="2000">
            <img src="http://drive.google.com/uc?export=view&id=1Ln9EMKy9DKBANgSsh-i79zaVlS3Kg8IZ" class="mx-auto d-block" alt="Digitalizacion De puesto De trabajo"style="width: 1080px;px; height:480px">
          </div>
          <div class="carousel-item">
            <img src="http://drive.google.com/uc?export=view&id=1e8xRnnyjaWr-NCEEypksEu8L471XonOo" class="mx-auto d-block" alt="Experiencia digital"style="width: 1340px;px; height:480px">
          </div>
          <div class="carousel-item">
            <img src="http://drive.google.com/uc?export=view&id=1E77BE5KIF5WOBqqiCjuJpbIkuRQ-RG_5" class="mx-auto d-block" alt="Experiencia digital"style="width: 1340px;px; height:480px">
          </div>
          <div class="carousel-item">
            <img src="http://drive.google.com/uc?export=view&id=1GW1l8_zvj0UW4g_FQKJGQgHBRShBbdWy" class="mx-auto d-block" alt="Experiencia digital"style="width: 1340px;px; height:480px">
          </div>
          <div class="carousel-item">
            <img src="http://drive.google.com/uc?export=view&id=1bYzWc6HLDuJSIN_zP3Kd2rp7n2BFaamq" class="mx-auto d-block" alt="Experiencia digital"style="width: 1340px;px; height:480px">
          </div>
          <div class="carousel-item">
            <img src="http://drive.google.com/uc?export=view&id=162ot_czT-oMG9MMJ9gMlVi_Septj_Vyf" class="mx-auto d-block" alt="Experiencia digital"style="width: 1340px;px; height:480px">
          </div>
          <div class="carousel-item">
            <img src="http://drive.google.com/uc?export=view&id=13QpeRvneSqBAYrXa1EvABlXQMu3lRDSY" class="mx-auto d-block" alt="Experiencia digital"style="width: 1340px;px; height:480px">
          </div>
 
          <button class="carousel-control-prev" type="button" data-bs-target="#carouselInterval" data-bs-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
      <span class="visually-hidden">Previous</span>
    </button>
    <button class="carousel-control-next" type="button" data-bs-target="#carouselInterval" data-bs-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>
      <span class="visually-hidden">Next</span>
    </button>
  </div>
 
        </div>
 
   <p></p>
   <p></p>
      <!--------------------------------------------- FILTROS PARA CONSULTAR LOS EVENTOS POR TEMATICA O TIPO  ------------------------------------------------------------------->
      <h3 class="text-center"style="color:black">Autoagendate </H3>
    <div class="container mt-3">
      <div class="row justify-content-center mb-3">
        <!----------------------------------------------------------------- PRIMER FILTRO "TEMATICA"---------------------------------------------------------------->
        <div class="input-group mb-3" style="width:30%">
          <label class="input-group-text" for="inputGroupSelect01">Tematica</label>
          <select class="form-select" id="text-box-frenteevento" onchange="buscarEventos()" >
 
            <option selected>Seleccionar...</option>
            <option value="Generalidades (Lunes)">Generalidades (Lunes)</option>
            <option value="Docs (Martes)">Docs (Martes)</option>
            <option value="Slides (Miercoles )">Slides (Miercoles)</option>
            <option value="Sheets (Jueves)">Sheets (Jueves)</option>
            <option value="Looker Studio (Viernes)">Looker Studio (Viernes)</option>
            <option value="Lo mejor del Google Week (Sabado)">Lo mejor del Google Week (Sabado)</option>
 
          </select>
        </div>
        <!----------------------------------------------------------------- SEGUNDO FILTRO "TIPO DE EVENTO"---------------------------------------------------------------->
        <div class="input-group mb-3" style="width:30%" >
          <label class="input-group-text" for="inputGroupSelect01">Tipo</label>
          <select class="form-select" id="text-box-TipoEvento" onchange="buscarEventosT()">
 
            <option selected>Seleccionar...</option>
            <option  value="Webinar" onchange="">Webinar</option>
            <option  value="Taller - Caso de uso"onchange="">Caso de uso</option>
            <option value="Charla" onchange="">Charla</option>
            <option value="Bonus track"onchange="">Bonus Track</option>
            <option value="Keynote"onchange="">Keynote</option>
 
          </select>
        </div>
         <!----------------------------------------------------------------- TERCER FILTRO "TIPO DE IDIOMA"---------------------------------------------------------------->
 
 <div class="input-group mb-3" style="width:30%">
          <label class="input-group-text" for="inputGroupSelect01">Idioma</label>
          <select class="form-select" id="text-box-Tipoidioma" onchange="buscarEventos()" >
            <option selected>Seleccionar...</option>
            <option  value="Español"  onchange="">Español</option>
            <option  value="Ingles"  onchange="">Ingles</option>
          </select>
        </div>
 
<p></p>
 
        <!------------------------------------Boton para limpiar la tabla cuando se haga una nueva consulta------------------------------>
        <button type="button" class="btn btn-primary" id="eliminar" onclick="buscarRegistros" style="width:20%; height:15%">Buscar</button>
        <p></p>
         <!----------------------------------------------------------------- TEXTBOX DONDE SE MUESTRAN FRENTE Y FECHA ------------------------------------------------------>
      </div>
      <div class="row justify-content-center mb-3">
        <div class="text-center"style="width:30%">
          <label> <h2 style="color:white">Frente</h2> </label>
          <input type="text" class="form-control" id="idOtro" placeholder="#" aria-label="first name" readonly>
        </div>
        <div class="text-center"style="width:30%">
          <label> <h2 style="color:white">Fecha del evento</h2> </label>
          <input type="text" class="form-control" id="idFecha" placeholder="Fecha del evento" aria-label="first name" readonly>
        </div>
      </div>
    </div>
 
      <!----------------------------------------------------------------- TABLA QUE NOS VA A TARER LA INFORMACION DE LA G. SHEET ------------------------------------------------------>
      <div class="Table-responsive col-20 p-5 center-block text-center">
         <div class="table-responsive">
            <table id="EventosTable" class="table Table-responsive-sm table align-middle table-striped table-bordered table-White table-sm text-center: center"border="1">
      <!----------------------------------------------------------------- ENCABEZADOS DE LA TABLA-------------------------------------------------------------------------------->
            <thead >
            <tr class="table-active">
            <th class="col-sm-1">Hora Colombia</th>
            <th class="col-sm-1">Tipo</th>
            <th class="col-sm-1">Nombre</th>
            <th class="col-sm-3">Descripcion</th>
            <th class="col-sm-1">Por</th>
            <th class="col-sm-1">Empresa</th>
            <th class="col-sm-1">Idioma</th>
            <th class="col-sm-1">Link Autogendar</th>
          </tr>
        </thead>
        <tbody id="eventosTableBody" class=" mt-5 ">
          <!------------------------------------------------------------ TEMPLATE, ACA SE INSERTARA LA TABLA DE LA G. SHEETS---------------------------------------------------------------------->
        </tbody>
        </table>
        </div>
 
      </div>
 
    </div>
    <template id="eventosRow">
      <tr>
        <td class="eventosTaquillero"></td>
        <td class="eventosTipo"></td>
        <td class="eventosNombre"></td>
        <td class="eventosFecha"></td>
        <td class="eventosHI"></td>
        <td class="eventosduracion"></td>
        <td class="eventosIdioma"></td>
        <td class=""><a type="button" class="btn btn-primary eventosAgendar" style="background-color:white; color:black" >Agendate aqui</a></td>
 
 
 
      </tr>
    </template>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
 
  <script>
function buscarEventos(evento){
  const nombreEventos = document.getElementById("text-box-frenteevento").value;
  const tipoEvento = document.getElementById("text-box-TipoEvento").value;
  const tipoIdioma = document.getElementById("text-box-TipoIdioma").value;
  let fechaEvento = document.getElementById("idFecha");
  let infofrente = document.getElementById("idOtro");
 
  google.script.run
  .withSuccessHandler(info => {
    let tableBody = document.getElementById("eventosTableBody");
    tableBody.innerHTML = "";
    if(info.length > 0 ){
      fechaEvento.value=info[0][0];
      infofrente.value=info[0][1];
 
      info.forEach(evento =>{
 
        const template = document.getElementById("eventosRow");
        const templateRow = template.content;
 
        let tr = templateRow.cloneNode(true);
 
        let colTaquill = tr.querySelector(".eventosTaquillero");
        let colTipo = tr.querySelector(".eventosTipo");
        let colNombre = tr.querySelector(".eventosNombre");
        let colFecha = tr.querySelector(".eventosFecha");
        let colHi = tr.querySelector(".eventosHI");
        let colDuracion =tr.querySelector(".eventosduracion");
        let colIdioma=tr.querySelector(".eventosIdioma");
        let colAgendar= tr.querySelector(".eventosAgendar")
 
        colTaquill.textContent = evento[2];
        colTipo.textContent =evento[3];
        colNombre.textContent =evento[4];
        colFecha.textContent =evento[5];
        colHi.textContent =evento[6];
        colDuracion.textContent =evento[7];
        colIdioma.textContent =evento[8]
        colAgendar.href=evento[9];
 
        tableBody.appendChild(tr)
 
      })
    } else {
      alert ("no se encontraron registros1")
    }
  })
  .BuscarRegistros(nombreEventos);
}
 
</script>
 
 
  <script>
  function buscarEventosT(evento){
    const nombreEventos = document.getElementById("text-box-frenteevento").value;
    const tipoEvento = document.getElementById("text-box-TipoEvento").value;
    let fechaEvento = document.getElementById("idFecha");
    let infofrente = document.getElementById("idOtro");
 
    google.script.run
    .withSuccessHandler(info => {
      let tableBody = document.getElementById("eventosTableBody");
      tableBody.innerHtml= "";
      if(info.length > 0 ){
        fechaEvento.value=info[0][0];
        infofrente.value=info[0][1];
 
        info.forEach(evento =>{
 
          const template = document.getElementById("eventosRow");
          const templateRow=template.content;
 
          let tr = templateRow.cloneNode(true);
 
          let colTaquill= tr.querySelector(".eventosTaquillero");
          let colTipo= tr.querySelector(".eventosTipo");
          let colNombre= tr.querySelector(".eventosNombre");
          let colFecha= tr.querySelector(".eventosFecha");
          let colHi= tr.querySelector(".eventosHI");
          let colDuracion=tr.querySelector(".eventosduracion");
          let colIdioma=tr.querySelector(".eventosIdioma");
          let colAgendar= tr.querySelector(".eventosAgendar")
 
          colTaquill.textContent = evento[2];
          colTipo.textContent =evento[3];
          colNombre.textContent =evento[4];
          colFecha.textContent =evento[5];
          colHi.textContent =evento[6];
          colDuracion.textContent =evento[7];
          colIdioma.textContent =evento[8]
          colAgendar.href=evento[9];
 
          tableBody.appendChild(tr)
 
 
        })
      }else{
        alert ("no se encontraron registros2")
      }
 
    })
    .BuscarRegistros(tipoEvento);
  }
</script>
}
 
 
 
    <p>
 
</p>
 
 
 
      </div>
    </div>
 
     <p>
 
</p>
  <script>
    var boton = document.getElementById("eliminar");
boton.addEventListener("click", function() {
  document.getElementById("eventosTableBody").innerHTML = '';
},true);
  </script>
 
 
 
 
 
  </body>
</html>
 
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder