Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
How can I pass a stored value from one "while" another "while"?

In Google Sheet, I have already list out all the filtered files as needed throughout the parent folder and child folder. I have pushed all the important details into the sheet as well.

My issue now is I am trying to get each childFolderId value from childFolders while and pass it into the fileIter while and then push into a list of array to be displayed in Google Sheet.

Here is the codes:

var parent = DriveApp.getFolderById(folderId);                          
                
getChildFiles(parentName, parent, currentSheet, list, excluded);

The main function is:

function getChildFiles(parentName, parent, sheet) {

var fileIter = parent.searchFiles("title contains 'completed'and title contains 'Verification 
Visit Direct Suppliers'and mimeType='application/vnd.openxmlformats- 
officedocument.spreadsheetml.sheet'"); 

var output = [];

var childFolders = parent.getFolders();

while (childFolders.hasNext()) {
  var childFolder = childFolders.next();
  var childFolderName = childFolder.getName();

getChildFiles(
  parentName + ' |--> ' + childFolderName, childFolder,sheet
  );   

 } 

while (fileIter.hasNext()) { 
 var file = fileIter.next();
 var fileName = file.getName();
 var fileID = file.getId();

 var path = parentName + ' |--> ' + fileName;

 output.push([fileID, fileName, path]);
}

 if (output.length) {
 var last_row = sheet.getLastRow();
 sheet.getRange(last_row + 1, 1, output.length, 3).setValues(output);
 SpreadsheetApp.flush();
} 

}

I am trying to get the childFolderId without messing up the filtering code. This is because if i insert the fileIter while inside the childFolders while, None of the files is listed in the google sheet.

But if i split both while i manage to list all the files i need except the childFolderId

How can I get the value of childFolderId and push it into the sheet?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda