:wave: i'm using SDF to build a restlet for integr...
# suitescript
k
šŸ‘‹ i'm using SDF to build a restlet for integration, but i'm having trouble with searches. it appears that if i do an ad-hoc search, i can't paginate it(?) [i just get an "unknown error"]. however, i also can't seem to reliably define a saved search as an object and deploy it (i start getting "a search has already been saved with that name", and the search that gets created is owned by my user (the user that ran the deploy command), not by the application i'm trying to deploy (so what happens if my user gets disabled?). any guidance on how to approach this? should i be using saved searches or not? how do i deal with large lists when i'm only going to be accessing parts of the list in batches?
e
I believe the saved search must be Public for SDF to interact with it. In general, I find saved searches in SDF to be quite tedious and usually exclude them from my projects, but I wouldn't say everyone should necessarily do that.
k
that was my feeling as well, but after bashing my head against the "unknown error" it seemed like maybe i should try to go this route
e
Not sure about the error, but you can absolutely paginate an ad-hoc search
k
oh really? hmm
that would be highly preferable
runPaginated just gave me "unknown error", but when i ran without pagination it worked
i couldn't get any further information (such as why it failed)
i think i can concoct an approach where pagination is unnecessary; i'll want to limit the max number of results returned, which seems like it should be doable
the only big list i'll have to deal with is "unassociated inventory items" i suppose
so i can say, "give me the first 100 items without an external id"
turns out the "unknown error" was using a filter expression (array of arrays/strings) as the value of the
filters
option to
search.create
instead of
filterExpression
, and the reason
.run()
seemed to work is that it didn't return results (as i thought it would) but rather, returned a cursor to get results from (which failed in the same way)
āœ… 1
e
I exclusively use the filter expression syntax with the
filters
option, so I'm not sure exactly what's going on there, but this feels like a problem for later if it's working now šŸ˜„
k
it's really hard to find clear examples/documentation, i picked this invocation up somewhere but no idea where
indeed
now i have actual errors i can troubleshoot šŸ˜‚
such as
You have entered an Invalid Field Value 21716 for the following field: salesorder
a little context would be helpful though
e
Here's a bunch of old tutorials I made about searches in SuiteScript: https://www.youtube.com/playlist?list=PLG2tK6Va2WUBP_JCf4nVAbFc6vGuB_lBm
šŸ‘ 1
k
it took 21 seconds to fail, if this is going to be typical... 😬
or are sandbox instances just slow?
e
They are slower, but typically not that much slower
k
the logic here is: • find or create customer • find or create sales order • (hit the error on save)
i didn't expect it to take that long
... anyway, new problem new thread, i'll dig into this once i have a bigger picture (thanks for the help!)
āœ… 1
new hypothesis on the "unknown error": numeric fields need "equalto" and string fields need "is" on the filters(?) which is a little bizarre, i can't seem to discern the concrete difference between the two. but i've got all the way to creating the salesorder line items now at least (after 47 seconds šŸ˜… )
e
^ very much worth internalizing
How complex are these searches? And how many Scripts and Workflows are deployed on the Sales Order? 47 seconds for one transaction seems egregious
k
it seems that the slowness is likely due to creating a new customer
which may or may not be relevant much of the time. the searches are not complex, but i couldn't say anything about the scripts and workflows. i'm just a dev, doing something for a client, and netsuite is huge and complex šŸ˜‰
the distinction between "is" and "equalto" seems really weird, but it suggests that netsuite doesn't think of strings as primitives. that may be relevant to the problem i currently have too, which is the distinction between
setCurrentSublistText
and
setCurrentSublistValue
...
e
You can see what is deployed to any given record type by navigating to Customization > Scripting > Scripted Records. Good bet there is heavy customization on the Customer record