How to search Custom Record in Netsuite Suite Script 2.0?

Hi All,

This is my 100th post so I want to post something important and which very hard to find.

We all know that Netsuite provide example code of search for native record or builtin record,
But if you try to search for custom record then script will throw error.
Previously Error message were very clean but now error messages are also becoming mess.

 So coming to point,

If we want to search built in record then use below code
var arrSearch = search.create({
                                                        type : search.Type.ITEM,
                                                        columns : yourColumns,
                                                        filters : yourFilters

                                                    });

Now search.Type.ITEM can be changed by other record types and we can get data from that record easily using search.

If we want to search Custom Record:

Use below code for custom record search. I tried with Capital Letters , you can try with small letters and let me know if that is also working or now.

var dynamicSearch = search.create({
                                                type : ‘CUSTOMRECORD_MYREC’,
                                                columns : yourColumns,
                                                filters : yourFilters

                                            });

** CUSTOMRECORD_MYREC is my custom record’s internal id(Record type).

Now How to get 1000 results?

Use below code and get 1000 results.

var dynamicSearchResults = dynamicSearch.run().getRange({
                                                                    start : 0,
                                                                    end : 1000
                                                                });

I hope this blog will help you, Please comment below if you have any thoughts on this or any better idea .
Please do comment if you think above code is not working or where to use this code.

Looking for Netsuite Course? Enroll Now to get a FREE demo on Netsuite Training.

Leave a Reply

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