This topic contains 6 replies, has 0 voices, and was last updated by kentroylance 7 years, 8 months ago.
-
AuthorPosts
-
January 25, 2017 at 8:13 pm #1249
kentroylanceIs it possible to do paging with nlapiSearchRecord where I can specify the page and the number of records I want returned of the full result set? I would like to be able to specify page 3, and return only 25 records, or do I have to figure all that out manually? If it is built in to the api, I would like to try and use it, otherwise, I can do it manually. BTW, I am trying to do this with a restlet.
I also need to be able to sort by any column either ascending or descending.
If this is possible, I am looking for a good example of how this is done with the suite script api.
Thanks,
Kent
This is a cached copy. Click here to see the original post. -
January 26, 2017 at 12:58 pm #1250
pcutlerI noticed that you posted in the SuiteScript 2.0 section but mentioned nlapiSearchRecord which is a SuiteScript 1.0 API. The SuiteScript 1.0 API for paginated searches is as follows:
var search = nlapiLoadSearch(‘customsearch_abc’);
var resultSet = search.runSearch();
var results = resultSet.getResults(50, 60); // gets results 50-59
There’s an equivalent SS 2.0 API as well.
-
January 26, 2017 at 2:47 pm #1251
kentroylanceThanks for your help. Since I am new to using SuiteScript, I am just trying to learn the basics. I have probably used more of SuiteScript 1 (mostly because there are more examples), but I am thinking I need to probably learn how to use the N/search Module from SuiteScript 2. I just wish there were better examples of how to use it in the right way, not just merely how to use it.
-
January 26, 2017 at 2:53 pm #1252
erictgrubaughSuiteScript 2.0 is still in its early stages of production, so there are few examples. Seems like most production-level work is still being done in 1.0, while most are still reserving 2.0 for side projects or very small tasks. You won’t go wrong learning the basics with 1.0 as the fundamental NetSuite concepts are the same between the versions.
-
February 8, 2017 at 10:43 am #1253
cblackburnSuiteScript 2.0 went GA in the 16.1 release, so 2-3 releases ago, depending on if you have upgraded to 17.1 yet.
The N/search module provides paged searching, a feature which is not available in SS 1.0. It is documented at the following URL.
+ /app/help/helpcenter.nl?fid=section_4345764122.html
-
February 23, 2017 at 10:49 pm #1254
ironsideSS1.0 supports paging via nlobjSearchResultSet.getResults(). You do have to decide what size your pages should be and do the math.
Another approach that is simpler is to just use NFT lazy search, where you can use methods like chunk() and take() to easily turn an indeterminate search result set and page it with a line of code.
-
February 24, 2017 at 12:50 pm #1255
kentroylanceThanks, I finally figured a way to do it, but I think I had to do way to much coding to get what I was after. Definitely an area that could be improved. As some point, I will move to SuiteScript 2.0 and hopefully that will be easier.
-
AuthorPosts
You must be logged in to reply to this topic.