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

184
Visualizações
Is there a way to replace a value in an array result of a custom search on Suitescripts?

I am trying to replace a value in a search.create function with a filter. the filter returns one or more objects, and i store them in an array. On accessing the array, i want to replace a certain value with 0, if a certain field 'lastinv' is empty. here is my code below;

// a is lastinv
if (a == null || a == '') {
  todate = format.format({
    value: todate,
    type: format.Type.DATE
  });

  // creates a custom search on a record with specific filters
  var reading = search.create({
    type: 'customrecord_ew_meterreading_form',
    columns: ['name', 'id', 'custrecord_ew_mr_metername', 'custrecordmeternumber', 'custrecord_ew_mr_site', 'custrecord1', 'custrecord_ew_meterreading_value'],
    filters: [{
      name: 'custrecord_ew_mr_site',
      operator: search.Operator.IS,
      values: site
    }, {
      name: 'custrecord1',
      operator: search.Operator.ON,
      values: todate
    }] // end of filter*/
  });
  
  // gets a custom search for the readings of a site on the
  // firstdate/lastdate of the month and stores in a array called ar_readings 
  reading.run().each(function(result) {
    ar_reading.push(result);
    return true;
  });
  
  return ar_reading;
}

And this next part is me trying to replace the value on a certain index;

for (var k = 0; k < firstReading.length; k++) {
  ar_mtrdata[k] = new Array();
  var l_meternumber = firstReading[k].getValue('custrecordmeternumber');
  var mtrdtls = getMeterDetails(l_meternumber);
  ar_mtrdata[k][0] = mtrdtls.getValue('itemid'); // Meternumber
  if (lastinv == '' || lastinv == undefined || lastinv == null) {
    ar_mtrdata[k][2] = 0;
  } else {
    ar_mtrdata[k][2] = firstReading[k].getValue('custrecord_ew_meterreading_value'); // previous reading
  }

  /* ... */
}

about 4 years ago · Santiago Gelvez
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