如何使用Netsuite的PHP工具包基于合作伙伴ID和SalesOrder自定义字段来获取SalesOrder?

问题描述 投票:1回答:1

真的希望对此有所帮助。

我正在尝试根据销售订单的自定义状态(字段)按合作伙伴获取销售订单。此自定义字段的文本为Hold for Release

我可以成功地通过合作伙伴获取交易记录,但是我似乎一辈子都无法弄清楚如何仅获取名称为Hold for Release的交易记录。这导致我确实需要最小化返回的巨大数据集。

我正在使用以下代码:

$service = new NetSuiteService();
        $service->setSearchPreferences(true,100);
        $customerSearchBasic = new PartnerSearchBasic();

        $searchValue = new RecordRef();
        $searchValue->type = 'partner';
        $searchValue->internalId = 39;  

        $searchMultiSelectField = new SearchMultiSelectField();
        setFields($searchMultiSelectField, array('operator' => 'anyOf', 'searchValue' => $searchValue));
        $customerSearchBasic->internalId = $searchMultiSelectField;

        $transactionSearchBasic = new TransactionSearchBasic();

        $searchMultiSelectEnumField = new SearchEnumMultiSelectField();
        setFields($searchMultiSelectEnumField, array('operator' => 'anyOf', 'searchValue' => "_salesOrder"));        

        $custSearchField = new SelectCustomFieldRef();
        $custSearchField->value = new ListOrRecordRef();
        $custSearchField->value->internalId = 1;
        $custSearchField->internalId = "custbody5";        

        $transactionSearchBasic->type = $searchMultiSelectEnumField;
        $transactionSearch = new TransactionSearch();

        $transactionSearch->basic = $transactionSearchBasic;
        $transactionSearch->partnerJoin = $customerSearchBasic;
        //$transactionSearch->customSearchJoin = $csb;
        $transactionSearch->customFieldList = new CustomFieldList();
        $transactionSearch->customFieldList->customField = array($custSearchField);


        $request = new SearchRequest();

        $request->searchRecord = $transactionSearch;
        $searchResponse

= $service->search($request);

但是,它不只返回“保留”用于发布事务。返回的部分数据如下所示:

["customFieldList"]=>
       object(CustomFieldList)#4511 (1) {
         ["customField"]=>
         array(71) {[3]=>
           object(SelectCustomFieldRef)#4516 (3) {
        ["value"]=>
        object(ListOrRecordRef)#4517 (4) {
          ["name"]=>
          string(16) "Hold for Release"
          ["internalId"]=>
          string(1) "1"
          ["externalId"]=>
          NULL
          ["typeId"]=>
          string(3) "173"
        }
        ["internalId"]=>
        string(3) "884"
        ["scriptId"]=>
        string(9) "custbody5"
      }

我想要的那些记录,这些我需要过滤掉:

[2]=>
      object(SelectCustomFieldRef)#4754 (3) {
        ["value"]=>
        object(ListOrRecordRef)#4755 (4) {
          ["name"]=>
          string(22) "Released to Production"
          ["internalId"]=>
          string(1) "5"
          ["externalId"]=>
          NULL
          ["typeId"]=>
          string(3) "173"
        }
        ["internalId"]=>
        string(3) "884"
        ["scriptId"]=>
        string(9) "custbody5"
      }

我到底在做什么错?

php api netsuite
1个回答
0
投票

经过大量的反复试验,我终于找到了解决方案。希望这对以后的人有所帮助。

$service = new NetSuiteService();
    $service->setSearchPreferences(true,100, false);
    $customerSearchBasic = new PartnerSearchBasic();

    $searchValue = new RecordRef();
    $searchValue->type = 'partner';
    $searchValue->internalId = 39;  

    $searchMultiSelectField = new SearchMultiSelectField();
    setFields($searchMultiSelectField, array('operator' => 'anyOf', 'searchValue' => $searchValue));
    $customerSearchBasic->internalId = $searchMultiSelectField;

    $transactionSearchBasic = new TransactionSearchBasic();

    $searchMultiSelectEnumField = new SearchEnumMultiSelectField();
    setFields($searchMultiSelectEnumField, array('operator' => 'anyOf', 'searchValue' => "_salesOrder"));        

    // is any of Eng. BOM Setup, Hold for Approval, Hold for Release, RFI, Eng. Submittal Drawings
    $hold_for_release = new ListOrRecordRef();        
    $hold_for_release->internalId = '1';

    $rfi = new ListOrRecordRef();        
    $rfi->internalId = '8';

    // you need to find the custom fields internal ID from within NetSuite
    /* Cancelled = 12
     * Change Order = 18
     * Customer Service = 7
     * Eng Bom SETUP = 10
     * Eng Submittal Drawings = 2
     * Hold for Approval = 3
     * Hold for Release = 1
     * Part Number Creation = 21
     * Partner Brand Submittal Drawings = 19
     * Pre Production Check - PB = 23
     * Pre Production Check - WG/Mix = 22
     * Purchasing = 11
     * Released to Production = 5
     * RFI = 8
     */

    $eng_bom_setup = new ListOrRecordRef();
    $eng_bom_setup->internalId = '5';

    $eng_submittal_drawings_2 = new ListOrRecordRef();        
    $eng_submittal_drawings_2->internalId = '2';        

    $domain = new SearchMultiSelectCustomField();
    $domain->scriptId = "custbody5";
    $domain->searchValue = array($hold_for_release,$rfi,$eng_submittal_drawings_2);
    $domain->operator = 'anyOf';

    $scfl = new SearchCustomFieldList();
    $scfl->customField = array($domain);
    $transactionSearchBasic->customFieldList = $scfl; 
    $transactionSearchBasic->type = $searchMultiSelectEnumField;
    $transactionSearch = new TransactionSearch();
    $transactionSearch->basic = $transactionSearchBasic;
    $transactionSearch->partnerJoin = $customerSearchBasic;

    $request = new SearchRequest();

    $request->searchRecord = $transactionSearch;
    $searchResponse = $service->search($request);
© www.soinside.com 2019 - 2024. All rights reserved.