Diego Serrano Diego Serrano - 9 months ago 62
Java Question

Netsuite get Transaction Saved Search Java

I am making an app in java that uses Netsuite's SuiteTalk web services to create a report. I defined a transaction saved search in which I use as a criteria the date and I print in the results the default Transaction columns plus the Department external ID and the sum of the amount. I run the saved search via UI and I get what I am expecting, however, when I try to get the information in my java code I keep getting null results. I have tried the java versions of the following solutions:

C# NetSuite WebServices: Get value from custom field in saved search (ItemSearchAdvanced)


However, none of this has worked for me. When I go to the Lists->Search->Saved Searches menu on my Netsuite UI, I am able to see my saved search when I set in the filters "General" and "Transaction". However, I haven't been able to retrieve it's information via API.

This is the code that I use to try to get the saved search data:

public void printReport() throws ExceededUsageLimitFault, UnexpectedErrorFault, InvalidSessionFault, ExceededRecordCountFault, RemoteException, UnsupportedEncodingException, SOAPException{

//METHOD 1: Transaction Search
TransactionSearchAdvanced sr = new TransactionSearchAdvanced();
//"customsearchreport" is the IF of my saved search
SearchResult res = _port.search(sr);

//METHOD 2: Item search

ItemSearchAdvanced isa = new ItemSearchAdvanced();
SearchResult resp = _port.search(isa);

//METHOD 3: General saved search

GetSavedSearchRecord gssr= new GetSavedSearchRecord();
//I set the record type as "transaction" as I created a transaction saved search.
GetSavedSearchResult gssre = _port.getSavedSearch(gssr);
System.out.println("Saved Search status: "+ gssre.getStatus().isIsSuccess());
RecordRefList srl = gssre.getRecordRefList();
RecordRef[] rr = srl.getRecordRef();
System.out.println("RecordRef[] size: " + rr.length);
for (int i = 0; i < rr.length; i++) {
RecordRef rref = rr[i];
System.out.println("External ID: " + rref.getExternalId());
System.out.println("Internal ID: "+ rref.getInternalId());
System.out.println("Name: "+ rref.getName());


With METHODS 1 and 2, I am not able to obtain results (I print "null"). The third method prints me 16 saved searches, however, none of the printed searches correspond to the ones I have created. When I check the saved search list through the UI, I see that there exist 21 non private saved searches and 4 have been created by me. From the 16 reports that are printed, one corresponds to a private saved search.

So, I don't get why I can't get my saved search result and what determines if a report is accessible through any method. Any help to obtain my savedSearch throough the API would be appreciated. Also, could any one explain how Netsuite determines which saved searches appear through any "get" method?


Answer Source

I solved it. The ID "customsearchreport" I was using is a UI ID. I had to use the InternalID for my report. Also, I was able to print my saved search IDs with the getSavedSearch() method by selecting the "All company members" checkbox in my the "Audience" section of my saved search.