Marty Zigman

Conversations with Marty Zigman

Certified Administrator • ERP • SuiteCloud

Marty Zigman LinkedIn

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc.. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM, and eCommerce business systems. Contact Marty to set up a conversation.

BiographyYouTubeLinkedInX (Twitter)

7 thoughts on “How To: Avoid Data Downloads with Excel Formula Based NetSuite Saved Search Queries

  1. Brian says:

    I’m really intrested in implementing the pull of a saved search into excel. Today we have numerous executive reports that I have to pull several saved searches out via export to csv .. paste those into tabs in excel and then run a macro that generates all the carts/graphs etc for the report. What i don’t see here is a step by step implementaiton. I get adding the function to Excel. That’s eazy. I take it i can then just use a call from a cell for the function. On the Suitelet side. The search appears to be contained in the Suitelet or do i need a saved search created and saved in NS? Could this be modified to do something like below where dataIn would be the saved search ID?

    function executeSavedSearches(dataIn) {
    try {
    if ( dataIn != undefined ) {
    nlapiLogExecution(‘DEBUG’, ‘dataIn’, JSON.stringify(dataIn));
    } else {
    nlapiLogExecution(‘ERROR’, ‘ERROR’, ‘dataIn undefined!’);
    return ‘{“error”:”dataIn undefined!”}’;
    }
    if (dataIn.type === undefined || dataIn.id === undefined) {
    nlapiLogExecution(‘ERROR’, ‘ERROR’, ‘Incomplete parameters’);
    return ‘{“error”:”Incomplete parameters!”}’;
    }
    var searchresults = nlapiLoadSearch(dataIn.type, dataIn.id);
    if (searchresults !== undefined) {
    nlapiLogExecution(‘DEBUG’, ‘Step’, “Run Search…”);
    var resultset = searchresults.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 > 0);
    nlapiLogExecution(‘DEBUG’, ‘results’, results);
    nlapiLogExecution(‘DEBUG’, ‘Number of sites’, index);
    return results;
    }
    return null;
    } catch(e) {
    var message = “ERROR”;
    if (e instanceof nlobjError) {
    message = e.getCode() + ‘: ‘ + e.getDetails();
    nlapiLogExecution(‘ERROR’, ‘system error – ‘ + e.getCode() + ‘\n’ + e.getDetails() + ‘\n’ + JSON.stringify(e.getStackTrace()));
    } else {
    message = e.toString();
    nlapiLogExecution(‘ERROR’, ‘unexpected error – ‘ + e.toString());
    }
    nlapiSendEmail(960, 960, ‘Error’, message);
    return null;
    }
    }

    Thought here – is that my current macro’s run off data pasted into given tabs. Each tab represents the CSV of a saved search. Could this all be plumbed together to get the results pulled into the Excel into their existing TAB placeholders.

  2. Marty Zigman says:

    In theory, you can do this. You may run into paging challenges and many argue that it’s not good to have insecure links pull data out of NetSuite. But did you see this article about getting data to Excel from NetSuite?

    Marty

  3. Brian says:

    I caught the link on the Excel & Reports. Issue i have with Reports is the data i’m pulling isn’t always available in the reports. I’ve tried modifying reports but they seem very structured and canned and not as flexabile as a saved search.

  4. Marty Zigman says:

    Hi Brian,

    We could leverage this pattern to effectively publish a RESTlet Endpoint which will pull the data out of NetSuite and drop it into Excel:

    https://blog.prolecto.com/2017/07/15/update-netsuite-directly-via-google-sheets-without-csv-files/

    Marty

  5. Louis says:

    Marty,

    Thank you for this tip. I understand how you did this with an anonymous login. Is there a way to do it while maintaining a secure login, or would that require a restlet instead of a suitelet?

  6. Marty Zigman says:

    Louis,

    You can program the system with a secure login. You just need to go through the mechanics of token based authentication. This article can help:
    https://blog.prolecto.com/2017/10/14/download-netsuite-oauth-token-based-authentication-sample-node-js-program/

    Marty

Leave a Reply

Your email address will not be published. Required fields are marked *