netsuite-saved-search
Node module wrapping making restlet call to execute a saved search in netsuite.
Installation
npm install netsuite-saved-search
Configuration
Set up a restlet in netsuite that can generically invoke a saved search.
{ if !optionssearchId return error: 'Must provide the searchId of the saved search' options: options ; return ;}
NOTE: the above can run into the 1000 record limit with netsuite. An alternative script to use is something like this:
{ if !optionssearchId return error: 'Must provide the searchId of the saved search' options: options ; var SLICE_LIMIT = 1000; var search = ; var resultset = search; var results = ; var index = 0; do var subset = resultset; if !subset break; subset; while subsetlength === SLICE_LIMIT; return results;}
Once this restlet is deployed, make a note of the External URL
in the deployment. Example:
https://rest.netsuite.com/app/site/hosting/restlet.nl?script=90210&deploy=1
Settings
Create a settings.js
somewhere with your netsuite credentials and restlet url
Required netsuite settings
moduleexports = netsuite: account: "1234567" email: "mynetsuiteaccount@here.tld" password: "p4ssw0rd" role: "3" restlet: "https://rest.netsuite.com/app/site/hosting/restlet.nl?script=90210&deploy=1" ;
Redis Options
If you don't want to use the standard redisClient settings, you can add a redis
option to the options:
moduleexports = netsuite: ... redis: host: 'a.b.c.d' port: 90210 cachePrefix: "blah:" ;
Usage
Check out some of the examples in the examples directory.
var settings = ;var search = settings; // This will try the cached version first, if not there will run and then cachesearch;
Cache Refresh
If you want to force a refresh of the cached results, pass in the options { forceRefresh: true}
search.fetch('customsearch_upinhere', { forceRefresh: true }, function (err, results) {...
Filters
An array of filters can be passed into the netsuite saved search:
var filters = 'modified' null 'onOrAfter' '1/30/2014 12:00 am';search
TODO
- Add optional EXPIRE times to the redis keys