Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda