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

85
Vistas
Transposed content issue

trust you're good. I'm working on a project where I sent data from an apk to a google sheet. The fact is that I sent the whole data to a sheet and I also send a kind of transposed data to other sheets, all with custom IDs.

Example here:

In Test_Sheet: ID Region Place Staff thing1 thing2 thing3 thing4 thing5

In test2 sheet:

ID thing1

ID thing2

ID thing3

ID thing4

ID thing5

All works fine but my issue is that when I have fewer items only, the ID will still be in the test2 sheet like all items are present.

ID thing1

ID thing2

ID thing3

ID

ID

Here is the code:

function doPost(e) {
  var ss = SpreadsheetApp.openById('XXXXXXXXXXXXXXXXXXX');
  var sh = ss.getSheetByName('Test_Sheet');
  var sh2 = ss.getSheetByName('test2')

  //custom ID 
  var scriptProperties = PropertiesService.getScriptProperties();
  var counter = scriptProperties.getProperty('counter') || 0;
  var formatDate = Utilities.formatDate(new Date(), "GMT+8", "ddMMyy");
  var zero = (counter < 10) ? '0' : '';
  var ID = "T" + formatDate + zero + counter++;
    if (counter > 99) counter = 0;
  scriptProperties.setProperty('counter', counter);

  \\send from apk
  var region = e.parameter.region;
  var place = e.parameter.place;
  var staff = e.parameter.staff;
  var thing1= e.parameter.thing1;
  var thing2= e.parameter.thing2;
  var thing3= e.parameter.thing3;
  var thing4= e.parameter.thing4;
  var thing5= e.parameter.thing5;
  
\\Test_Sheet
  sh.appendRow([ID, region, place, staff, thing1, thing2, thing3, thing4, thing4]);

\\test2
  sh2.appendRow([ID, thing1]);
  sh2.appendRow([ID, thing2]);
  sh2.appendRow([ID, thing3]);
  sh2.appendRow([ID, thing4]);
  sh2.appendRow([ID, thing5]);

}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If the problem is that the new rows are created even though an ID does not exists for these records, then first make sure that the ID does exist before writing to the sheet. So in your code, you would do:

 if( thing1 ) sh2.appendRow([ID, thing1])
 if( thing2 ) sh2.appendRow([ID, thing2]) 
 // … and so on
about 4 years ago · Juan Pablo Isaza Denunciar
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