title: Pagination in Suitescript 2.0 Netsuite
body: <p>I tried implementing netsuite pagination in suitescript 2.0, the prev button is working but instead of 20 search data it's return like whole. Next button is not working always throwing error INVALID_PAGE_RANGE</p>
  
  <p>Here is the suitelet code </p>
  
  <pre><code>         var loadSearch = search.load({
              id: 'customsearch_inv123'
  
          });
          var i = 0;
  
          var pagedData = loadSearch.runPaged({
              pageSize: 20
          });
  
          pagedData.pageRanges.forEach(function (pageRange) {
  
              var lastPageRange = pagedData.pageRanges[pagedData.pageRanges.length - 1];
  
              var Page = pagedData.fetch({
                  index: lastPageRange.index
              });
  
              if (context.request.parameters.next) {
                  Page = Page.next(); 
              }
  
              if (context.request.parameters.prev) {
                  Page =Page.prev();
              }
  
              Page.data.forEach(function (result) {
  
                  var number = result.getValue({
                      name: 'inventorynumber'
                  });
  
                  if (number) {
  
                      updateSublist.setSublistValue({
                          id: 'custpage_number',
                          line: i,
                          value: number
                      });
                  }
  
  
                  i++;
  
              });
          });
  
  
          // submit button
  
          form.addSubmitButton({
              label: 'Submit'
          });
  
          form.addButton({
              id: '_next',
              label: 'Next',
              functionName: 'next'
          });
  
          form.addButton({
              id: '_prev',
              label: 'Prev',
              functionName: 'prev'
          });
  
  
          form.clientScriptModulePath = 'SuiteScripts/client.js';
  </code></pre>
  
  <p>In client script i wrote the function next and prev, and redirected to the same page with next or prev parameters and based on that i called page.next and page.prev.</p>
  
  <p>If you have implemented this please help me. </p>
  
  <p>here is client code.</p>
  
  <pre><code> next: function () {
                  window.location.href = 'example.com' + '&amp;next=t';
              },
  
              prev: function () {
                  window.location.href = 'example.com' + '&amp;prev=t';
              }
  </code></pre>