Getting values from a saved search formula column

Requirement

Formula columns are all named the same internally, which is why you can’t directly get their values individually. For instance, if you have two Formula (Numeric) columns in your search, both internal column names will be “formulanumeric”. Therefore, using getValue('formulanumeric') will get only the first formula value.

Solution

require(['N/search'], function(search) {
  // A saved search containing multiple formula result columns
  var s = search.load(1234);

  s.run().each(function(result) {
    log.debug(result.getValue(result.columns[5]));
    log.debug(result.getValue(result.columns[1]));
    log.debug(result.getValue(result.columns[3]));
  });
});

Leave a comment

Your email address will not be published. Required fields are marked *