1

希望这里有人有NetSuite经验!我正在通过 Netsuite 网络服务访问保存的搜索以检索销售订单。出于某种原因,订单上的商品如下:

[item] => Array
    (
        [0] => SearchColumnSelectField Object
            (
                [searchValue] => RecordRef Object
                    (
                        [internalId] => 1088
                        [externalId] => 
                        [type] => 
                        [name] => 
                    )

它不显示产品代码,而是显示 internalId,即使屏幕上保存的搜索正确显示了产品。如何从中获取产品代码?

4

3 回答 3

1

您选择了错误的列和/或搜索字段值而不是文本或 itemfield:name。我将编辑我的答案并在我找到它时添加更多内容。这是来自我的 ns 经验,虽然是套件脚本。

使用我看到的参考文档:发布 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

但是,客户端和服务器套件脚本都是为了强制执行定制的业务规则而编写的,无论在 NetSuite 中创建或更新记录的机制如何,这些规则都可能需要强制执行。对于部署 SuiteCloud 合作伙伴应用程序并希望确保其业务规则仍然得到遵守的客户来说尤其如此。由于 Client SuiteScript 通常具有特定于浏览器的行为,需要用户操作且无法在 Web 服务调用期间自动运行,因此 NetSuite 建议您禁用 Client SuiteScript 并针对需要在所有情况下强制执行的业务条件部署 Server SuiteScript。

要指定在 Web 服务调用期间永远不执行服务器套件脚本,请在设置 > 集成 > Web 服务的 Web 服务首选项页面上启用禁用服务器端脚本首选项。

重要提示:
仅当通过 Web 服务提交的数据不需要遵守可通过 Server SuiteScript 执行的自定义业务逻辑和工作流时才启用此首选项。


于 2013-06-15T10:14:10.690 回答
0
<?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;
    } 

    ?>
于 2013-07-17T12:40:04.937 回答
0

在您的搜索首选项中将 bodyFieldsOnly 设置为 FALSE。

$NSservice = new NetSuiteService();
$NSservice->setSearchPreferences(false, 100, true);
于 2013-07-07T13:53:25.067 回答