npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

netsuite-saved-search

v0.1.6

Published

Wrap making restlet call to execute a saved search in netsuite, with optional caching.

Downloads

18

Readme

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.

function executeSavedSearch(options) {
  if ( !options.searchId ) {
    return { error: 'Must provide the searchId of the saved search', options: options };
  }
  return nlapiSearchRecord(null, options.searchId, null, null);
}

NOTE: the above can run into the 1000 record limit with netsuite. An alternative script to use is something like this:

function executeSavedSearch(options) {
  if ( !options.searchId ) {
    return { error: 'Must provide the searchId of the saved search', options: options };
  }

  var SLICE_LIMIT = 1000;
  var search = nlapiLoadSearch(null, options.searchId);
  var resultset = search.runSearch();

  var results = [];

  var index = 0;
  do {
    var subset = resultset.getResults(index, index+1000);
    if ( !subset ) break;
    subset.forEach( function (row) {
      results.push(row);
      index++;
    });
  } while (subset.length === 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

module.exports = {
  netsuite: {
    account: "1234567",
    email: "[email protected]",
    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:

module.exports = {
  netsuite: {
    ...
  },
  redis: {
     host: 'a.b.c.d',
     port: 90210,
     cachePrefix: "blah:"
  }
};

Usage

Check out some of the examples in the examples directory.

var settings = require('./config/settings');
var search = require('netsuite-saved-search')(settings);
    
// This will try the cached version first, if not there will run and then cache
search.fetch('customsearch_upinhere', function (err, results) {
  if (err) onFailure(err);
  console.log(results);
});

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.fetch(searchId, { forceRefresh: true, filters: filters },

TODO

  • Add optional EXPIRE times to the redis keys