Ahora, hace aproximadamente una hora, alguien aquí tuvo la amabilidad de ayudarme a resolver un problema que tenía con GApps Script, ahora, al intentar arreglar/agregar algunas cosas, uhhhhh, creo que ya no funciona, al menos en cierta parte. Entonces, déjame explicarte, este es el código hasta ahora. Se supone que verifica varios casos y si la condición es verdadera, copia esas filas de una hoja a la otra, sin embargo, esto funciona perfectamente ( y esto solía funcionar, creo, así que sé por qué no funciona ahora ) las filas que se han copiado, no se eliminan después de eso, ¿por qué?
var sourceSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("NUEVOS INGRESOS Y EXPEDIENTES EN TRAMITE"); var archive = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("CASOS ARCHIVADOS/FINALIZADOS"); if (sourceSheet.getLastRow()==1){ SpreadsheetApp.getActive().toast('No data!', 'End of script 🗃️') return } var data = sourceSheet.getRange(2,1,sourceSheet.getLastRow()-1,sourceSheet.getLastColumn()).getValues() var archiveData = [] var lines = [] var line = 1 var col = 31 // AF try { data.forEach(function (row) { if (row[col]=="Finalizado_Archivado") { archiveData.push(row) lines.push(line) } else if(row[col]=="Remitida_a_otro_juzgado_conexidad"){ archiveData.push(row) lines.push(line) } else if(row[col]=="Remitida_UACF"){ archiveData.push(row) lines.push(line) } else if(row[col]=="Remitida_a_otro_juzgado_por_recusacion"){ archiveData.push(row) lines.push(line) } else if(row[col]=="Remitida_a_otro_Juzgado_por_cuestion_de_turno"){ archiveData.push(row) lines.push(line) } else if(row[col]=="Remitida_a_otros_fueros"){ archiveData.push(row) lines.push(line) } }) archive.getRange(archive.getLastRow() + 1, 1, archiveData.length, archiveData[0].length).setValues(archiveData) lines.reverse().forEach(x => sourceSheet.deleteRow(x)); SpreadsheetApp.getActive().toast('Rows '+lines.flat()+' hab been archived !', 'End of script 🗃️') } catch (e) { SpreadsheetApp.getActive().toast('No data to be archived!', 'End of script 🗃️') } } // || "Remitida_a_otro_juzgado_conexidad"||"Remitida_UACF"||"Remitida_a_otro_juzgado_por_recusacion"|| //"Remitida_a_otro_Juzgado_por_cuestion_de_turno"||"Remitida_a_otros_fueros"Prueba esto:
function elfunko() { const ss = SpreadsheetApp.getActive(); const ssh = ss.getSheetByName("Sheet1");//Changed sheet name const ash = ss.getSheetByName("Sheet2"); const spA = ["Finalizado_Archivado", "Remitida_a_otro_juzgado_conexidad", "Remitida_UACF", "Remitida_a_otro_juzgado_por_recusacion", "Remitida_a_otro_Juzgado_por_cuestion_de_turno", "Remitida_a_otros_fueros"]; if (ssh.getLastRow() == 1) { SpreadsheetApp.getActive().toast('No data!', 'End of script 🗃️'); return; } const vs = ssh.getRange(2, 1, ssh.getLastRow() - 1, ssh.getLastColumn()).getValues() const archiveData = []; let d = 0;//delete counter vs.forEach((r, i) => { if (~spA.indexOf(r[31])) { archiveData.push(r); ssh.deleteRow(i + 2 - d++); } }); ash.getRange(ash.getLastRow() + 1, 1, archiveData.length, archiveData[0].length).setValues(archiveData); }