0
votes

I'm trying to test some code in the netsuite debugger, but everytime I run

require(['N/search','N/log'], function(search) {
  function loadAndRunSearch() {
    var mySearch = search.load({id: 'customsearch1868', type:search.Type.ASSEMBLY_ITEM});
    var myPagedData = mySearch.runPaged();
    myPagedData.pageRanges.forEach(function(pageRange){
      var myPage = myPagedData.fetch({index: pageRange.index});
      myPage.data.forEach(function(result){
        var entity = result.getValue({name: 'itemid'});
        log.debug({title:id})
      });
    });
  }
  loadAndRunSearch();
});

Netsuite throws this "unexpected error":

{"type":"error.SuiteScriptError","name":"UNEXPECTED_ERROR","message":null,"stack":["load(N/search/searchObject.js)","loadAndRunSearch(adhoc$-1$debugger.user:3)","<anonymous>(adhoc$-1$debugger.user:13)","<anonymous>(adhoc$-1$debugger.user:1)"],"cause":{"type":"internal error","code":"UNEXPECTED_ERROR","details":null,"userEvent":null,"stackTrace":["load(N/search/searchObject.js)","loadAndRunSearch(adhoc$-1$debugger.user:3)","<anonymous>(adhoc$-1$debugger.user:13)","<anonymous>(adhoc$-1$debugger.user:1)"],"notifyOff":false},"id":"edaacc5f-3b3f-42e9-925b-4b7187152a45-2d323032302e30362e3132","notifyOff":false,"userFacing":false}

What can I do to resolve this?

1
Does your saved search run in the UI without any issue? Seems the search cannot be loaded... - Jala
It does work, and I'm even able to call to the search in suitescript 1.0 without error. - Nick the coder

1 Answers

0
votes

type: is not part of the search.load call in SS2.0

Try your code with it removed