When I try to load search using SuiteScript, it re...
# suitescript
b
When I try to load search using SuiteScript, it returns me this error
Error - TypeError: rawColumns[i].push is not a function
When I run that search in UI, it works. Also it has many Formula, and summary type columns but not sure why this error is showing
e
share code?
b
just simple. @ec
Copy code
const searchID="aaa"
            let tmpSearch = search.load({
                id: searchID
            });
@ec Here is the saved search code when I try to export using chrome extension
Copy code
var invoiceSearchObj = search.create({
   type: "invoice",
   filters:
   [
      ["mainline","is","T"], 
      "AND", 
      ["status","anyof","CustInvc:A"], 
      "AND", 
      ["type","anyof","CustInvc"], 
      "AND", 
      ["duedate","after","today"]
   ],
   columns:
   [
      search.createColumn({
         name: "entity",
         summary: "GROUP",
         label: "Name"
      }),
      search.createColumn({
         name: "formulanumeric",
         summary: "SUM",
         formula: "CASE WHEN {duedate} - {today} > 1 AND {duedate} - {today} < 30 THEN {amount} ELSE 0 END",
         label: "1-30 Days"
      }),
      search.createColumn({
         name: "formulanumeric",
         summary: "SUM",
         formula: "CASE WHEN {duedate} - {today} > 31 AND {duedate} - {today} < 60 THEN {amount} ELSE 0 END",
         label: "31-60 Days"
      }),
      search.createColumn({
         name: "formulanumeric",
         summary: "SUM",
         formula: "CASE WHEN {duedate} - {today} > 60 AND {duedate} - {today} < 90 THEN {amount} ELSE 0 END",
         label: "61-90 Days"
      }),
      search.createColumn({
         name: "formulanumeric",
         summary: "SUM",
         formula: "CASE WHEN {duedate} - {today} > 91 THEN {amount} ELSE 0 END",
         label: "Over 90 Days"
      }),
      search.createColumn({
         name: "formulanumeric",
         summary: "SUM",
         formula: "CASE WHEN {duedate} - {today} > 0 AND {duedate} - {today} <= 1 THEN {amount} ELSE 0 END",
         label: "Current"
      })
   ]
});
e
do you get errors running that (create code)
b
No let me try
search.create doesn't show error. but it shows an error when it runs
Here is running code
Copy code
let searchRes = invoiceSearchObj.run().getRange(0, 1);
            log.debug('searchRes', JSON.stringify(searchRes));
@ec any idea please?
runPaged()
also works
This error happens when we have Formula Numeric columns
d
not seeing anywhere in your posted script the code
rawColumns[i].push(…)
which is what the error is telling you is wrong
as a side note, read up about referencing result columns when you have multiple of the same formula field type (formulanumeric for example) https://stackoverflow.com/a/57596153
I see you've been helped on the thread you created in #C298P0BCK 👍 https://netsuiteprofessionals.slack.com/archives/C298P0BCK/p1680721259507319