I'm trying send some data from firebase to google sheets. I used the method push() to insert the data into a variable and call it in "resource {values: duplicitiesWithJudicialCharges}".
I know that have more than one value, but in my google sheet it's apearing just one line.
From what I've observed, the last value erases the previous one and sticks to the first line. I would like all the values in the rows to appear in sequence.
const resultduplicitiesWithJudicialCharges = firestore.collection("Processos judiciais").where("documentosDosautores", "==", cpf)
const duplicitiesWithJudicialCharges = new Array()
resultduplicitiesWithJudicialCharges.get().then((querySnapshot) => {
querySnapshot.forEach((parentDoc) => {
//functions.logger.log(parentDoc.id, " => ", parentDoc.data())
parentDoc.ref.collection("fee-arbitrations - Base de Execução").where('arbitramentoDeHonoráriosBE', '==', arbitramentoHonorários).get().then((querySnapshot) => {
querySnapshot.forEach(async (childDoc) => {
//duplicitiesWithJudicialCharges.push(`${'arbitramentoHonorários'}: ${arbitramentoHonorários}`, `${'nome'}: ${nome}`, `${'processoBE'}: ${childDoc.data().processoBE}`)
duplicitiesWithJudicialCharges.push([`${arbitramentoHonorários}`, `${nome}`, `${childDoc.data().processoBE}`])
//duplicitiesWithJudicialCharges.unshift([`${arbitramentoHonorários}`, `${nome}`, `${childDoc.data().processoBE}`])
functions.logger.log(duplicitiesWithJudicialCharges)
// let res = [duplicitiesWithJudicialCharges]
// functions.logger.log(res)
const updateOptions = {
auth: jwtClient,
spreadsheetId: 'XXXXXXXXXXXXXXXXXXXXXXXXXX',
//range: 'grpr!A12',
range: '3. Duplicidades judiciais!A2:H1000',
valueInputOption: 'USER_ENTERED',
resource: { values: duplicitiesWithJudicialCharges },
}
await google.sheets({ version: 'v4', auth: jwtClient }).spreadsheets.values.clear({
range: '3. Duplicidades judiciais!A2:H1000', // SEMPRE QUE FOR QUERER DELETAR, VERIFIQUE A AS LINHAS E COLUNAS QUE POSSUEM VALOR
spreadsheetId: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
// Request body metadata
requestBody: {
// request body parameters
// {}
},
});
google.sheets({ version: 'v4', auth: jwtClient }).spreadsheets.values.update(updateOptions)
})
})
})
})
Below I bring an example of data captured by the function that I want to send to the spreadsheet.
This is the result that appears when I send the data to the spreadsheet.
I would like google spreadsheet to show this result:
Does anyone knows where is the problem?