0

我正在尝试从 Netsuite 的某个仓库退回所有库存。我遇到了一些问题,想知道是否有人能指出我正确的方向。我要查询的仓库的 internalId 是 16。当我进行搜索时,它返回 0 个项目 - 但不会失败。

这是我正在使用的 PHP 代码。

<?php
require_once 'PHPtoolkit.php';
require_once 'login_info.php';
global $myNSclient;


$internalID = '16'; //Internal ID of the warehouse I want to query to see what inventory it has

$inventorySearch = new nsComplexObject("ItemSearchBasic");

$searchValue = new nsRecordRef(array('type' => 'location', 'internalId' => $internalID ));

$multiSelect = new nsComplexObject('SearchMultiSelectField');
$multiSelect->setFields(array('operator'=>'anyOf','searchValue'=>$searchValue,"operatorSpecified" => true));


$inventorySearch->setFields(array('location'=>$multiSelect));

try
{
    $searchResponse = $myNSclient->search($inventorySearch);
    $totalRecords = $searchResponse->totalRecords;
    if ($totalRecords > 0)
    {
        echo "records found";
        foreach ($searchResponse->recordList as $record)
        {
            echo "<pre>";
            print_r($record);
            echo "</pre>";
        }
    }
    else
    {
        echo "No result found.";
    }

}
catch (Exception $e)
{
    echo $e;
    echo "Item is not found. Please try again.";
    exit();
}

这是 SOAP 请求

  <?xml version="1.0" encoding="UTF-8" ?> 
- <Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:core_2011_2.platform.webservices.netsuite.com" xmlns:ns2="urn:common_2011_2.platform.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="urn:messages_2011_2.platform.webservices.netsuite.com">
- <Header>
- <passport actor="http://schemas.xmlsoap.org/soap/actor/next">
  <email>xxxxx</email> 
  <password>[Content Removed for Security Reasons]</password> 
  <account>xxxxxx</account> 
  <role internalId="3" xsi:type="RecordRef" /> 
  </passport>
  </Header>
- <Bod
y>
- <search>
- <searchRecord xsi:type="ItemSearchBasic">
- <location operator="anyOf">
  <searchValue internalId="16" type="location" /> 
  </location>
  </searchRecord>
  </search>
  </Body>
  </Envelope>
4

2 回答 2

3
$inventorySearch = new nsComplexObject("ItemSearchBasic"); 
$inventorySearch->setFields(array(
    "location" => array(
        "operator" => "anyOf",
        "searchValue" => array(
            "type" => "location",
            "internalId" => $internalId
        )
     )
));

然后,做你的尝试/捕捉。

但是当我看到这个时,你想要获得项目可用性。这是一个完全不同的电话。

$filter = new nsComplexObject ( 'ItemAvailabilityFilter' );
$filter->setFields ( array (
    "location" => array (
        "operator" => "anyOf",
        "searchValue" => new nsRecordRef ( array (
            "type" => "location",
            "internalId" => $internalId 
        ) ) 
    ) 
) );
于 2012-07-03T05:35:19.633 回答
1

我花费了大量时间使用 PHPToolKit v2011.2 端点构建自己的自定义搜索,并在拔掉头发后让它们工作,因为没有那么多示例。随着 v2012_2 端点的引入,事情发生了变化,我必须重新学习我之前解决的问题。我“强烈”建议您使用 SAVED SEARCH,而不是尝试发明在 PHP 中进行所有搜索的方法。在 Netsuite 中创建一个已保存的搜索,并使用您创建的搜索的 internalId 从您的 PHP 调用 SAVED SEARCH。

于 2013-05-20T20:14:47.197 回答