Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
861 views
in Technique[技术] by (71.8m points)

javascript - Netsuite Suitescript API - Searching Transaction records returns duplicates

I am attempting a basic search query of the 'transaction' records (I have also attempted this with 'salesorder' with similar results). The query has no filters, and requests only the internalid as a search column, but for some reason the results include the same record multiple times... sometimes MANY times.

[
  {
    "internalid": "1984"
  },
  {
    "internalid": "1984"
  },
  {
    "internalid": "1984"
  },
  {
    "internalid": "1998"
  },
  {
    "internalid": "1998"
  },
  {
    "internalid": "1998"
  },
  {
    "internalid": "2490"
  },
  {
    "internalid": "2490"
  },
  {
    "internalid": "2573"
  },
  {
    "internalid": "2573"
  },
  {
    "internalid": "2491"
  },

Why would this happen? Is there any way to get the query to only return each record once?

EDIT: Adding code as requested

var filters = [];
var columns = [];
columns.push(new nlobjSearchColumn('internalid'));

var searchResults = nlapiSearchRecord('transaction', null, filters, columns);   

return searchResults;   
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Please add a filter,

mainline is TRUE

If you are using saved search via code, please add additional filter

as new nlobjSearchFilter('mainline', null, 'is', 'T') or ['mainline', 'is', 'T']

as the search result pull up the same internal id, multiple times for all line items

EDIT: For the provided code example

var columns = [];
columns.push(new nlobjSearchColumn('internalid'));

var searchResults = nlapiSearchRecord('transaction', null, ['mainline', 'is', 'T'], columns);   

return searchResults; 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...