使用PHP工具包在netsuite中编辑自定义字段

使用PHP工具包在netsuite中编辑自定义字段,php,netsuite,Php,Netsuite,我看到了一些如何添加新订单的示例,但是我正在尝试使用PHP工具包更新现有订单的自定义字段。有谁能从这个开始告诉我吗?我不知道从哪里开始 这是添加新订单的代码 <?php require_once '../PHPToolkit/NetSuiteService.php'; $service = new NetSuiteService(); $svr = new getSelectValueRequest(); $svr->fieldDescription = new GetSele

我看到了一些如何添加新订单的示例,但是我正在尝试使用PHP工具包更新现有订单的自定义字段。有谁能从这个开始告诉我吗?我不知道从哪里开始

这是添加新订单的代码

<?php

require_once '../PHPToolkit/NetSuiteService.php';

$service = new NetSuiteService();

$svr = new getSelectValueRequest();
$svr->fieldDescription = new GetSelectValueFieldDescription();
$svr->pageIndex = 1;

$priceFields = array(
    'recordType'  => RecordType::salesOrder,
    'sublist'    => 'itemList',
    'field'    => 'price',
    'filterByValueList'    => array(
        'filterBy'    => array(
            array(
            'field'    => 'item',
            'sublist'    => 'itemList',
            'internalId'        => '458',
        )
            )
    )
);


if ($id != null) {
    echo "Custom price level id is " . $id . "\n";
} else {
    echo "Custom price level not found " . $id . "\n";
}

$so = new SalesOrder();
$so->entity = new RecordRef();
$so->entity->internalId = 21;
$so->itemList = new SalesOrderItemList();
$soi = new SalesOrderItem();
$soi->item = new RecordRef();
$soi->item->internalId = 104;
$soi->quantity = 3;
$soi->price = new RecordRef();
$soi->price->internalId = $id;
$soi->amount = 55.3;
$so->itemList->item = array($soi);

$request = new AddRequest();
$request->record = $so;

$addResponse = $service->add($request);

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

?>

您需要一个customFieldList对象,它是一个自定义字段数组。自定义字段的不同数据类型有不同的对象-下面是字符串自定义字段。我使用utf8_编码来处理通常看不到的奇怪字符

$customFieldList = new CustomFieldList();
$customField = new StringCustomFieldRef();
$customField->value = utf8_encode("contents of string custom field");
$customField->internalId = 'custbody_whatever_your_field_is';
$customFieldList->customField[] = $customField;

$so->customFieldList = $customFieldList;

谢谢,我如何从netsuite中选择我要更新的特定订单?这就是我拥有的,id 21是我要更改的订单id吗?在销售订单上设置内部id$so->internalid=1234;谢谢你的帮助。我得到一个无效的\u KEY\u或\u REF,指定的密钥无效。在回信中。这是我的密码,2074是订单,229是自定义交易主体字段的内部id。知道它为什么不工作吗?2074是订单的内部ID,还是最终用户可以看到的数字?在UI中调出记录-内部ID是URL末尾的数字。