Has anyone ever seen `search.run()` and `search.ru...
# suitescript
s
Has anyone ever seen
search.run()
and
search.runPaged()
return different results? I have a pretty simple searchDefinition on a custom record, and the
runPaged()
is returning no results and
.run()
is returning 1 (as expected).
question not answered 1
Basically there is a forecast detail record, with item/location/quantity, this search sums up all the quantities and takes the average. Heres an example searchDef that would log.
Copy code
let searchDef = {
   type: "customrecord_rp_forecast_detail",
   filters: [
      [
         "custrecord_rp_fd_forecast",
         "anyof",
         "1"
      ],
      "AND",
      [
         "custrecord_rp_fd_item",
         "anyof",
         [
            "2827"
         ]
      ],
      "AND",
      [
         "custrecord_rp_fd_location",
         "anyof",
         [
            "3"
         ]
      ],
      "AND",
      [
         "custrecord_rp_fd_week_beginning",
         "within",
         "7/10/2021",
         "10/7/2021"
      ]
   ],
   columns: [
      {
         name: "custrecord_rp_fd_item",
         join: null,
         summary: "GROUP",
         label: null,
         type: null,
         function: null,
         formula: null,
         sortdir: "NONE",
         whenorderedby: null,
         whenorderedbyjoin: null,
         whenorderedbyalias: null
      },
      {
         name: "custrecord_rp_fd_location",
         join: null,
         summary: "GROUP",
         label: null,
         type: null,
         function: null,
         formula: null,
         sortdir: "NONE",
         whenorderedby: null,
         whenorderedbyjoin: null,
         whenorderedbyalias: null
      },
      {
         name: "formulanumeric",
         join: null,
         summary: "SUM",
         label: null,
         type: null,
         function: null,
         formula: "{custrecord_rp_fd_demand}/90",
         sortdir: "NONE",
         whenorderedby: null,
         whenorderedbyjoin: null,
         whenorderedbyalias: null
      }
   ],
   title: "Forecasted Demand"
}
If I run with
run()
it gives me a single result as expected
Copy code
search.create(searchDef).run().getRange(0,1000)[0].getAllValues();
{GROUP(custrecord_rp_fd_item): Array(1), GROUP(custrecord_rp_fd_location): Array(1), SUM(formulanumeric): ".777777777777777777777777777777777777778"}
If I run with
runPaged()
it gives me nothing
Copy code
search.create(searchDef).runPaged({pageSize: 1000}).fetch({index: 0}).data
[]
I also noticed if I take the date criteria out of the search, both
run()
and
runPaged()
give me the same expected result. I assume I have stumbled onto some weird NS bug with dates in criteria.
d
oooooooh, that's an interesting one. potentially
run()
and
runPaged()
are interpreting the dates as either
DD/MM/YYYY
or
MM/DD/YYYY
Check out this: https://stackoverflow.com/a/66892420. That answer is using
format.format(…)
I expect that Shawn/Stalbert would say to use NFT which has momentJS to deal with dates
s
I actually do use moment to deal with the dates, I hate
N/format
so I completely avoid using it.
d
Absolutely same re:`N/format`, it always is a pain to work with