Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!