简体   繁体   English

Netsuite获取事务保存的搜索Java

[英]Netsuite get Transaction Saved Search Java

I am making an app in java that uses Netsuite's SuiteTalk web services to create a report. 我正在用Java开发一个应用程序,该应用程序使用Netsuite的SuiteTalk Web服务创建报告。 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. 我定义了一个保存交易的搜索,其中以日期为标准,并在结果中打印默认的交易列以及部门外部ID和金额总和。 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. 我通过UI运行保存的搜索,并且得到了期望的结果,但是,当我尝试在Java代码中获取信息时,却一直得到空结果。 I have tried the java versions of the following solutions: 我尝试了以下解决方案的Java版本:

C# NetSuite WebServices: Get value from custom field in saved search (ItemSearchAdvanced) C#NetSuite WebServices:从保存的搜索中的自定义字段中获取值(ItemSearchAdvanced)

http://www.anyforum.in/question/web-service/netsuite/How-to-get-data-from-saved-search-through-webservice-request/345 http://www.anyforum.in/question/web-service/netsuite/How-to-get-data-from-saved-search-through-webservice-request/345

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". 当我转到Netsuite UI上的“列表”->“搜索”->“保存的搜索”菜单时,在过滤器“常规”和“交易”中进行设置后,便可以看到保存的搜索。 However, I haven't been able to retrieve it's information via API. 但是,我无法通过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
        sr.setSavedSearchId("customsearchreport");
        SearchResult res = _port.search(sr);
        System.out.println(res.getTotalRecords());

        //METHOD 2: Item search

        ItemSearchAdvanced isa = new ItemSearchAdvanced();
        isa.setSavedSearchId("customsearchreport");
        SearchResult resp = _port.search(isa);
        System.out.println(resp.getTotalRecords());

        //METHOD 3: General saved search 

        GetSavedSearchRecord gssr= new GetSavedSearchRecord();
        //I set the record type as "transaction" as I created a transaction saved search.
        gssr.setSearchType(SearchRecordType.transaction);
        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"). 使用方法1和方法2,我无法获得结果(我打印“ null”)。 The third method prints me 16 saved searches, however, none of the printed searches correspond to the ones I have created. 第三种方法为我打印了16个保存的搜索,但是,没有一个打印的搜索与我创建的搜索相对应。 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. 通过UI检查保存的搜索列表时,我发现存在21个非私有保存的搜索,其中4个是我创建的。 From the 16 reports that are printed, one corresponds to a private saved search. 在打印的16个报告中,一个对应于私有保存的搜索。

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. 通过API获取我的saveSearch的任何帮助将不胜感激。 Also, could any one explain how Netsuite determines which saved searches appear through any "get" method? 另外,有人可以解释Netsuite如何通过任何“获取”方法确定哪些已保存的搜索吗?

Thanks! 谢谢!

I solved it. 我解决了 The ID "customsearchreport" I was using is a UI ID. 我使用的ID“ customsearchreport”是一个UI ID。 I had to use the InternalID for my report. 我必须为报告使用InternalID。 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. 另外,通过选择已保存搜索的“受众群体”部分中的“所有公司成员”复选框,我可以使用getSavedSearch()方法打印已保存的搜索ID。

I solved them 我解决了

Before the second script, we must increase the number pages limit like this: 在第二个脚本之前,我们必须增加页数限制,如下所示:

SearchPreferences sp = new SearchPreferences();
                sp.pageSize = 1000;
                _service.searchPreferences = sp;

                SubsidiarySearch subsidiarySrch = new SubsidiarySearch();
                SearchResult srchResult = _service.search(subsidiarySrch);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM