1

I have a small C# console application who's sole purpose is to receive records from a "Saved Search" in NetSuite(via SuiteTalk). I've been able to successfully connect and receive records from NetSuite for my Saved Search(the search runs fine through the web interface too), however when I attempt to access the results of the "Saved Search" through my application, I am unable to view them because the search object that is returned does not contain any data in the "recordList" property:

//Connect
var dataCenterAwareNetSuiteService = new DataCenterAwareNetSuiteService("XXXXXX");
dataCenterAwareNetSuiteService.Timeout = 1000 * 60 * 60 * 2;

//Adds Credentials etc...
dataCenterAwareNetSuiteService.tokenPassport = createTokenPassport(); 

//Setup Preferences
var prefs = new Preferences();
prefs.warningAsErrorSpecified = true;
prefs.warningAsError = false;
dataCenterAwareNetSuiteService.preferences = prefs;

var searchPrefs = new SearchPreferences();
dataCenterAwareNetSuiteService.searchPreferences = searchPrefs;
dataCenterAwareNetSuiteService.searchPreferences.pageSize = 5;
dataCenterAwareNetSuiteService.searchPreferences.pageSizeSpecified = true;
dataCenterAwareNetSuiteService.searchPreferences.bodyFieldsOnly = false;
dataCenterAwareNetSuiteService.searchPreferences.returnSearchColumns = false;

//Search
var tranSearchAdv = new TransactionSearchAdvanced();
var tranSearchRow = new TransactionSearchRow();
var tranSearchRowBasic = new TransactionSearchRowBasic();

tranSearchAdv.savedSearchId = "XXXX";
tranSearchRowBasic.internalId = 
    new SearchColumnSelectField[] { new SearchColumnSelectField() };
tranSearchRowBasic.tranId = 
    new SearchColumnStringField[] { new SearchColumnStringField() };
tranSearchRowBasic.dateCreated = 
    new SearchColumnDateField[] { new SearchColumnDateField() };
tranSearchRowBasic.total = 
    new SearchColumnDoubleField[] { new SearchColumnDoubleField() };
tranSearchRowBasic.entity = 
    new SearchColumnSelectField[] { new SearchColumnSelectField() };

tranSearchRow.basic = tranSearchRowBasic;
tranSearchAdv.columns = tranSearchRow;

//No errors, 
//this works correctly and returns the "Saved Search" with the correct "totalRecords"
//but results.recordList == null while results.totalRecords = 10000000+
var results = dataCenterAwareNetSuiteService.search(tranSearchAdv);

I appears to me that the "recordList" object is the principal way data is retrieved from the results of a search(Related Java Example, Another Here). This is also the way the example API does it.

I have run this on multiple "Saved Search's" with the same results. I don't understand how you can have more than one record in "totalRecords" and yet the "recordList" remains null? Is there some configuration option that has to be set to allow me to access this property. Or maybe it's a security thing, the API user I have setup should have full access, is there anything else that need to be granted access?

NetSuite SuiteTalk is not well documented, and most of the examples online are not in C#, and not dealing with the issues that I'm experiencing. These factors make it very difficult to determine why the previously mentioned behavior is occurring, or even, to discover any alternative methods for retrieving the resulting data from the source "Saved Search".

Does anyone have any insight into this behavior? Is this the correct method of retrieving results from SuiteTalk? Is there any configuration from the API or Web Side that needs to be changed?

Update 1

I've also tried using the alternative way of getting result data by accessing the "searchRowList" object from the "SearchResult" object(suggested by @AdolfoGarza) However it returns mostly empty fields(null) similar to the "recordList" property I do not see a way to retrieve "Saved Search" data from this method.

Community
  • 1
  • 1
David Rogers
  • 2,601
  • 4
  • 39
  • 84

2 Answers2

1

Try getting the results with results.searchRowList.searchRow , thats how it works in php.

Adolfo Garza
  • 2,966
  • 12
  • 15
  • Yes, good suggestion, I actually have another example API that does just that, but when I take that approach, I get a number of results consistent with the "pageSize" but the results(TransactionSearchRow/TransactionSearchRowBasic) returned have nearly all fields set to null(With the exception of the total, entitiy, internalID, and dateCreated fields), I don't see any way that I can retrieve any data generated from the "Saved Search" query through this method. The symptoms seem similar with the first issue, where the query is getting results, but for some reason I can't retrieve them. – David Rogers Nov 07 '16 at 14:41
  • Yeah use advanced to get more info. Also, even in advance you might not get the data you need all in one go. Searches are tricky in Suitetalk so you might need to adjust the search to get the data you need. You might want to look into coding a Restlet or protected Suitelet to get the search results and take advantage of Suitescript which has better and faster APIs. – Adolfo Garza Nov 07 '16 at 15:09
  • What do you mean by "advanced", I believe I am already using a "Advanced Search"(TransactionSearchAdvanced), but of course everything returned is still null. As for the query, its returns exactly the data I'm looking for through the NetSuite UI, I just can't get that through the API. – David Rogers Nov 07 '16 at 15:16
  • Oh I see, sorry I got confused by the TransactionSearchRowBasic you have there, I don't think you need them, you just need the id. Also, you might need to play around with the returnSearchColumns and the bodyFieldsOnly, in my experience turning one or the other to true provides more info such as columns but for some reason you don't get the names anymore, just internal ids. Anyways, this is an example of how it works in PHP. http://pastebin.com/raw/NSSy34uN – Adolfo Garza Nov 07 '16 at 15:29
  • Me too, I think you were right, I didn't need that, once I removed it I was able to retrieve the results set through the "basic" property. Thanks for your help :) – David Rogers Nov 07 '16 at 19:38
0

I was able to resolve the issue by removing this line in the code:

tranSearchRow.basic = tranSearchRowBasic;

Then like @AdolfoGarza reccomended, retrieving the results from "basic" field in "results.searchRowList"

For some reason the template API that I was using was setting up a "TransactionSearchAdvanced" referencing a blank "TransactionSearchBasic" record, not sure why but this was causing the results from "searchRowList" to be null. After removing it I now get non-null values in the proper fields.

As for "recordList", it's still null, not sure why, but as I have my data I don't think I'll continue to dig into this.

David Rogers
  • 2,601
  • 4
  • 39
  • 84
  • SuiteTalk, unfortunately leaves allot to the developer to figure out how to retrieve and manipulated result sets. I think this question/answer helps clarify some of it(at least in my case). The other part of the equation is what to do with the data once you can access it, I think this [post](https://community.boomi.com/thread/2736) helps clarify some of the questions around this. – David Rogers Nov 07 '16 at 19:34