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

时间:2014-01-14 23:56:00

标签: php netsuite

我看到了一些如何添加新订单的示例,但我正在尝试使用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;
}

?>

1 个答案:

答案 0 :(得分:2)

您需要一个customFieldList对象,它是一个自定义字段数组。自定义字段的不同数据类型有不同的对象 - 下面是字符串自定义字段。我utf8_encode处理你通常看不到的怪异角色。

$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;