Join using SuiteScript 2.0 and ‘N/search’ Module

N/search

Load the search module to create and run on-demand or saved searches and analyse and iterate through the search results. You can use this module to do the following:

  • Search for a single record using keywords
  • Create and save searches
  • Load and run previously saved searches
  • Search for duplicate records
  • Return a set of records that match filter criteria you define

Use Case

Suppose we have a situation where User wants to load and run a saved search joining a customer with the contact. Means the customer want to get result from the 2 records simultaneously one is Customer and another us contact. In this Situation we are using join for 2 different records and the join operator helps in getting result based on the condition. The sample code below loads and runs an existing Customer saved search which is joined to a contact entity.

Code Snippet

function runSearchgetResult() {

            var mySearch = search.load({

                id: “searched”

            });

            var searchResult = mySearch.run().getRange(0, 999);

            for (var i = 0; i < searchResult.length; i++) {

                                                var contactid = searchResult[i].getValue({

                                                            name: “entityid”,

                                                            join: “contact”,

                                                            });

                log.debug(‘logs’, contactid)

            }

        }

Not all joins that appear in the UI are supported in SuiteScript. To see which joins are supported for a particular search, start by going to SuiteScript Supported Records. Click the record type that you want to execute the search on. Then look to see which joins are supported for the record type.

Reference : netsuite.com, netsuite help  and netsuite guide.

Feel free to reach out netsuite solution providernetsuite implementationnetsuite consultation , netsuite customizationnetsuite Supportnetsuite Training  

contact us at: Email : info@smilingcoders.com

Facebook : https://www.facebook.com/Smiling-Coders-Netsuite-Training-Implementation-and-Support-1591053827660082/

Linkedin : https://www.linkedin.com/company/netsuite-academy/


2 Comments

Briantug

April 2, 2020 at 4:13 pm

I enjoy the info on your site. Thank you so much.

    Smiling Coders

    April 11, 2020 at 1:04 am

    Briantug,Thanks for words. please write for any suggestions

Leave a Reply