Hey, NetSuite Developers!

There’s one NetSuite module member that you all should familiarize yourself with and that is N/task.SearchTask.

N/task.SearchTask is probably my most favorite feature in NetSuite’s SuiteScript 2.0 next to Map/Reduce. Thanks to @erictgrubaugh for mentioning it in the Slack community.

If this is your first time hearing about it, now is the time to check it out.

What it does is it fetches the saved search results and exports it to a CSV file.

When I tested it way back when it was newly introduced last 2018.2 Release, I was impressed that I automatically wrote an article about it. Had I known it a few months earlier, I could have saved hours of coding in my project.

I am listing down its cool features and why you should include this in your SuiteScript vocabulary:

  1. It is straightforward.

    The most obvious advantage. You just need some parameters like the file ID, the saved search ID, the script and you’re pretty set!

  2. It doesn’t require many lines of codes.

    With the old way, you would have to make use of N/search and N/file methods, run the search, display the data, save it in the file cabinet and so on. With this Object, it’s as short as seven lines of code!

  3. No need for additional character manipulation.

    With the old way, you might need to use some native Javascript methods for special characters, especially the comma. With this Object, no need to go through that hassle!

  4. It’s been proven to be faster than its integration counterpart.

    I had a project recently where we had an integration that fetches some saved search results and builds a CSV file out of it. It was previously performing for 15 minutes for thousands of records. When we removed that integration and just let this script do a similar job, it only took around 1 minute. Fascinating, isn’t it?


What do you need to get started? The list is pretty short:

  1. Empty CSV File

    That’s right. You would need an empty CSV file and save it in the File Cabinet to get started.

  2. Saved Search

    Before starting, prepare the saved search that you will use in your script. Below you will find a screenshot of my saved search results. Notice that I intendedly put special characters in my test because, in the old way, you would need some character formatting to avoid messing up your output.

  3. The script (of course!)

    For your convenience, here’s my sample code in a scheduled script format:


* @NApiVersion 2.x

* @NScriptType ScheduledScript

* @NModuleScope SameAccount




* @param {record} record

* @param {search} search


function(task) {

var FILE_ID = 20; 

var SEARCH_ID = 19;

function execute(scriptContext) {

var searchTask = task.create({

taskType: task.TaskType.SEARCH


searchTask.savedSearchId = SEARCH_ID;

searchTask.fileId = FILE_ID;

var searchTaskId = searchTask.submit();


return {

execute: execute



Sample Output

You may see the sample output file below. The header names and search results were displayed just as how it should be. The special characters were presented just fine. Amazing!


Did you learn something from this article? I would love to hear your story. Feel free to connect through the Contact form.


Do you have NetSuite Development needs? Do you need help with a solution like this? Click on the link below and let’s have a chat about your project requirements!

Contact us for your NetSuite needs!


    1. I haven’t had a chance to test that scenario. I checked the Help Guide but didn’t find any limits. I think it’s worth confirming this with NetSuite Support.

  1. Hello,
    Is it possible to export multiple saved searches with one script?
    I need to export 11 saved searches and prefer the to this with one scheduled script.

Leave a Reply