希望有人有NetSuite经验!我正在通过Netsuite web服务访问保存的搜索以检索销售订单。由于某些原因,订单上的项目以以下方式显示:
[item] => Array
(
[0] => SearchColumnSelectField Object
(
[searchValue] => RecordRef Object
(
[internalId] => 1088
[externalId] =>
[type] =>
[name] =>
)
它不显示产品代码,而是显示internalId,即使屏幕上保存的搜索正确显示产品。我怎么能从这个得到产品代码?
您选择了错误的列和/或搜索字段值而不是文本或itemfield:name。我会编辑我的答案,并添加更多,因为我发现它。这是从我的ns经验,虽然与suitescript
使用我看到的参考文档:张贴TRX摘要字段:
<complexType name="PostingTransactionSummaryField">
<sequence>
<element name="period" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<element name="account" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<element name="parentItem" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<element name="item" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<element name="entity" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<element name="department" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<element name="class" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<element name="location" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<element name="subsidiary" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
</sequence>
</complexType>
或也使用参考文档我看到:GetPostingTransactionSummaryResult:
<complexType name="GetPostingTransactionSummaryResult">
<sequence>
<element ref="platformCore:status" minOccurs="1" maxOccurs="1"/>
<element name="totalRecords" type="xsd:int" minOccurs="0"/>
<element name="pageSize" type="xsd:int" minOccurs="0"/>
<element name="totalPages" type="xsd:int" minOccurs="0"/>
<element name="pageIndex" type="xsd:int" minOccurs="0"/>
<element name="postingTransactionSummaryList" type="platformCore:PostingTransactionSummaryList" minOccurs="0" maxOccurs="1"/>
</sequence>
</complexType>
在另一个不相关的主题上,我发现了这个:
指定Web服务上下文
要使表单在Web服务和UI中的行为不同,您可以执行以下操作之一:
编写特定于上下文的SuiteScript代码,并使用nlapiGetContext函数来分支代码
在Web服务中禁用SuiteScript
然而,客户端和服务器的SuiteScripts都是为了执行定制的业务规则而编写的,无论在NetSuite中创建或更新记录的机制如何,都可能需要执行这些规则。对于部署了SuiteCloud合作伙伴应用程序并希望确保其业务规则仍然得到尊重的客户来说尤其如此。由于客户端SuiteScript通常具有需要用户操作的浏览器特定行为,并且不能在Web服务调用期间自动运行,因此NetSuite建议您禁用客户端SuiteScript并部署服务器端SuiteScript,以应对在所有情况下都需要强制执行的业务条件。
要指定Server SuiteScript不应该在Web服务调用期间执行,请在设置>的Web服务首选项页面上启用禁用服务器端脚本首选项。集成在Web服务。
重要:
只有当通过Web服务提交的数据不需要遵循可能通过Server SuiteScript执行的自定义业务逻辑和工作流时,才启用此首选项。
将bodyFieldsOnly设置为FALSE。
$NSservice = new NetSuiteService();
$NSservice->setSearchPreferences(false, 100, true);
<?php
$order_date = date('Y-m-d H:i:s');
// create array of fields
$itemArr = array();
$i = 0;
foreach($order_items_product as $keyProduct =>$valueProduct){
//if you not have internal id of item in netsuuite then please add the item in the netsuite and try.
$netsuiteItemId = 'Your Item Internal id Which is in the Netsuite Item';
$itemArr[$i]['item']['internalId'] = $netsuiteItemId;
$itemArr[$i]['quantity'] = $valueProduct['qty'];
$i++;
}
if (!define('LF', "'n")) {
define('LF', "'n");
}
/* for use in formatting custom addresses since NetSuite converts to <br> */
//Billing Address Information
/* this example has the customer address info in a db record, just pulled into $row */
$billAddress = stripslashes($order->order_custom_fields['_billing_first_name'][0]) . ' ' . $order->order_custom_fields['_billing_last_name'][0] . LF;
$billAddress .= stripslashes($order->order_custom_fields['_billing_address_1'][0]).LF;
$billAddress .= stripslashes($order->order_custom_fields['_billing_address_2'][0]).LF;
$billAddress .= stripslashes($order->order_custom_fields['_billing_country'][0]).LF;
$billAddress .= stripslashes($order->order_custom_fields['_billing_state'][0]) . ' - ' . $order->order_custom_fields['_billing_postcode'][0] . ', ' . LF;
$billAddress .= $order->order_custom_fields['_billing_phone'][0] . ', ' . $order->order_custom_fields['_billing_email'][0];
//Shipping Address Information
$shipAddress = stripslashes($order->order_custom_fields['_shipping_first_name'][0]) . ' ' . $order->order_custom_fields['_shipping_last_name'][0] . LF;
$shipAddress .= stripslashes($order->order_custom_fields['_shipping_address_1'][0]).LF;
$shipAddress .= stripslashes($order->order_custom_fields['_shipping_address_2'][0]).LF;
$shipAddress .= stripslashes($order->order_custom_fields['_shipping_city'][0]).LF;
$shipAddress .= stripslashes($order->order_custom_fields['_shipping_state'][0]) . ', ' . $order->order_custom_fields['_shipping_postcode'][0] . ', ' . LF;
$shipAddress .= $order->order_custom_fields['_billing_phone'][0] .', '. $order->order_custom_fields['_billing_email'][0];
$purchaseOrderFields = array (
'entity' => array ('internalId' => $internal_Id, 'type' => 'customer'),
'shippingCost' => $order->order_shipping,
'shipMethod' => $order->payment_method,
'toBeEmailed' => true,
//'tranId' => $order->order_custom_fields['Transaction ID'][0],
//'tranDate' => date('Y-m-d H:i:s'),
'source' => 'littlecrate',
'createdFrom' => 'littlecrate.com',
'discountRate' => $order->order_custom_fields['_order_discount'][0],
'taxRate' => $order->order_custom_fields['_order_tax'][0],
'email' => $order->billing_email,
//'shipDate' => date('Y-m-d H:i:s'),
'shipMethod' => $order->shipping_method,
'shippingCost' => $order->order_shipping,
'shippingTax1Rate' => $order->order_shipping_tax,
'paymentMethod' => $order->payment_method,
//'taxTotal' => $order->order_tax,
//'total' => $order->order_total,
'billAddress' => $billAddress,
'shipAddress' => $shipAddress,
'itemList' => array (
'item' => $itemArr
)
);
$salesOrder = new nsComplexObject('SalesOrder');
$salesOrder ->setFields($purchaseOrderFields);
$addResponse = $myNSclient->add($salesOrder );
if (!$addResponse->isSuccess) {
echo "Order Information is Not Inserted Into The Netsuite. Please Contact to Administration.";
exit;
}
?>