<@U9U62UJMD> what happens if you hard code the str...
# suitescript
j
@fkrauthan what happens if you hard code the string values instead of using template literals test it with
'custrecord_123456_tran_payer'
instead of
custrecord_${config.client.id}_tran_payer
there is a bug with the how server's javascript engine and the netsuite api treat concatenated strings
s
is this bug documented anywhere? I've heard it come up before but haven't run into it myself. Is there a reliable repro case?
seeing NS behaving badly with my own eyes helps cement it in my memory 🙂
runnable in script debugger
Copy code
require(["N/search"], function(search) {
  var dynamicValue = "foo";
  var filterExpr = [
    "formulanumeric: case when regexp_like({memo}, '(^|\\W)" + dynamicValue + "(\\W|$)') then 1 else 0 end",
    "equalto",
    "1"
  ];

  log.debug({ title: typeof filterExpr[0] }); // string
  log.debug({ title: typeof filterExpr[1] }); // string

  // throws SSS_INVALID_SRCH_FILTER_EXPR_TYPE: Malformed search filter expression, first two elements must be strings.
  search.create({
    type: search.Type.SALES_ORDER,
    filters: filterExpr,
  });
  var x = 0;
});
s
is it a problem specifically with how filter expressions are parsed, or does it seem to have a fundamental problem with the javascript implementation? filter expression syntax is a bit special because there must be some layer of Java language parsing those string expressions (and probably building Java nlobjFilter objects).
j
the author of the usergroup thread discussed problems with getValue (but the error message was less clear), so it's not limited to searches
currentRecord.getValue({ fieldId: 'custrecord_myrecord_' + month + '_quantity' }) // SSS_MISSING_REQD_ARGUMENT
I believe it has something to do with how NetSuite passes the java model of your javascript parameters to its underlying java implementation