php - Netsuite PHP ItemSearchBasic 问题

标签 php mysql erp netsuite

我正在尝试从 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>

最佳答案

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

然后,做你的 try/catch。

但正如我所看到的,您想要获得商品可用性。这是一个完全不同的调用。

$filter = new nsComplexObject ( 'ItemAvailabilityFilter' );
$filter->setFields ( array (
    "location" => array (
        "operator" => "anyOf",
        "searchValue" => new nsRecordRef ( array (
            "type" => "location",
            "internalId" => $internalId 
        ) ) 
    ) 
) );

关于php - Netsuite PHP ItemSearchBasic 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11299850/

相关文章:

python - Odoo 中从非 transient 模型到 transient 模型的 Many2One 或 One2Many 关系的解决方法

php - Vtiger 自动登录问题,无需输入凭据

php - 使用 Javascript 打开两个新选项卡

php 每个循环插入数据两次,而不是按预期插入每一行

php - 我如何解析这个字符串 : a:10:{1:0;s:7 :"default";i:1; . ..?

PHP pdo : update + insert and then select returns null

mysql - 在 ERD 建模中,关系是否映射到数据库表

php - mysql 在 php 中使用空值左连接

database - ERP和DBMS有什么区别?

OAuth2 - 如何同时从多个浏览器保持登录状态?