I'm suddenly having problems when I try to run a s...
# suitescript
a
I'm suddenly having problems when I try to run a summary search with formulas via script, the search runs ok in the UI but I get unexpected error when I try to run it via script(loading and running the existing search).
m
Maybe export your saved search as script and try directly in your script Check if you have an error
m
First I would check permissions though. Is it running as admin or current user. Maybe the user doesn't have access to a record in the search. If it's not permissions I would probably do like Mb suggested and export the columns and criteria into the script and comment all the formula lines and uncomment them one at a time to see which line is producing the error.
a
I understand your logic and steps to figure out what is wrong with the search. However I'm expecting that loading a search that works in the UI would not trigger an unexpected error with native NetSuite API.
Copy code
const oSearch = search.load({
    id: pSavedSearch
}).runPaged({ pageSize: 1000 })
This should not trigger an unexpected error if the search is working in the UI, this is a bug, meaning NetSuite own API method is unable to properly load searches when the search have certain combination of summary or formulas.
m
I agree. And that it is an "unexpected error" is not the least bit helpful. I haven't run into it when loading a search before.
a
I know is a problem with the columns definition, if I replace the columns by columns created by me it works.
In general I'm finding a lot of unexpected errors recently... right now I'm loading a transaction and setting a Date Time field value, and I'm getting unexpected error instead of something more useful.
m
I haven't noticed increased errors personally, but I don't think any of the accounts I work on have been upgraded yet.
r
Copy code
const oSearch = search.load({
    id: pSavedSearch
}).runPaged({ pageSize: 1000 })
Have you checked if you are not loading what NetSuite calls as
standalone
search. There are certain search types that you have to specify the search type when loading the search. See more information in this link under the
options.type
description: https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4345775360.html#search.load(options)
n
@alien4u I think this is your problem ☝️ Which record type your search is based on? Not all the searches are allowed to load in SuiteScript
a
I'm loading a regular transaction search, which I can load and runPaged as long as I replace the columns, I think this a related to formula columns. However not sure why it will error out with: Unexpected Error.