Netsuite PHP工具包更新销售订单

时间:2016-07-05 13:49:07

标签: php netsuite

我需要更新销售订单中的custbody字段:

该字段是一个下拉列表和一个复选框。如何将“检查”值发送到复选框字段?结果返回“Success”,但该字段永远不会从其现有值更新。这是我的代码。

$customStringFieldList = new StringCustomFieldRef();
$customStringFieldList->internalId = "custbody_order_status";
$customStringFieldList->value = "Cancelled";

$customSelectFieldList = new SelectCustomFieldRef();
$customSelectFieldList->value = new ListOrRecordRef();
$customSelectFieldList->value->internalId = 49;
$customSelectFieldList->internalId = 'custbody_shipping_confirmed';
//send true?

$basicCustomRecord = new SalesOrder();
$basicCustomRecord->internalId = "114467"; // internal id of the custom record you want to update
$basicCustomRecord->recType = new RecordRef();
$basicCustomRecord->customFieldList = new CustomFieldList();
$basicCustomRecord->customFieldList->customField = array($customStringFieldList, $customSelectFieldList);

$updateRequest = new UpdateRequest();
$updateRequest->record = $basicCustomRecord;

$updateResponse = $service->update($updateRequest);

var_dump($updateResponse);
if (!$updateResponse->writeResponse->status->isSuccess) {
    echo "UPDATE ERROR";
    exit();
} else {
    echo "UPDATE SUCCESS, id " . $updateResponse->writeResponse->baseRef->internalId;
}

2 个答案:

答案 0 :(得分:0)

我可能会错过它;但是,我没有看到您在哪里设置已选中或未选中的值。

也就是说,在SuiteScript 1.0中,您可以使用“T”或“F”来选中并取消选中一个复选框,作为字段的值。

在2.0中,我通常能够使用true或false(布尔值,而不是字符串)。

答案 1 :(得分:0)

以下是你将如何为将来遇到这个问题的人做这件事:

 $si = 'internal value of the option you can find this in custom settings';

 $customSelectFieldList = new SelectCustomFieldRef();
 $customSelectFieldList->value = new ListOrRecordRef();
 $customSelectFieldList->value->internalId = $s_id;
 $customSelectFieldList->scriptId = 'custbody_order_status';


  $aBooleanField = new BooleanCustomFieldRef();
  $aBooleanField->value = true;
  $aBooleanField->scriptId = 'custbody_move_confirmed';



            $SalesOrderId = 437127;
            $SalesOrderRecord = new SalesOrder();
            $SalesOrderRecord->internalId  = $SalesOrderId;


            $SalesOrderRecord->customFieldList = new CustomFieldList();
            $SalesOrderRecord->customFieldList->customField = array($customSelectFieldList,$aBooleanField);

            $updateRequest = new UpdateRequest();
            $updateRequest->record = $SalesOrderRecord;

            $updateResponse = $service->update($updateRequest);


            if (!$updateResponse->writeResponse->status->isSuccess) {
                echo "UPDATE ERROR";
                exit();
            } else {
                echo "UPDATE SUCCESS, id " . $updateResponse->writeResponse->baseRef->internalId;


            }