9

Netsuite 的文档非常缺乏,它们涵盖了基础知识,然后让您自由探索。任何没有大量 PHP 知识的人试图使用他们的 php 工具包都会跪下求饶。

在整个项目中的任何时候,它都是反复无常的,并试图弄清一切,直到一切开始工作。

我很难为销售订单分配自定义字段,我知道它必须是对象的对象的对象,才能将 xml 分层以便肥皂接管,但是用什么用什么?

我有一些我工作的代码正在到达某个地方,但它抱怨它不是正确的 RecordRef 类型。如果有人与 Netsuite 合作并感受到我的痛苦,请在我拔掉所有头发之前把你的知识借给我。

提前致谢。

代码:

$customFields = array('internalId' => 'custbody_new_die_yn','value' => array('name' => 'custbody_new_die_yn','internalId' => 'NO'));
$customObject = new nsComplexObject("SelectCustomFieldRef");
$customObject->setFields($customFields);

$salesOrderFields = array(

    'entity'        => new nsRecordRef(array('internalId' => $userId)),
    'paymentMethod' => array('internalId' => 8),
    'ccNumber'      => 4111111111111111,
    'ccExpireDate'  => date("c", mktime(0,0,0,11,1,2011)),
    'ccName'        => 'Test Testerson',
    'itemList'  => array(
        'item'  => array(
            'item'      => array('internalId' => 5963),
            'quantity'  => 5
        )
    ),
    'department' => new nsRecordRef(array('internalId' => 1)),
    'class' => new nsRecordRef(array('internalId' => 47)),
    'customFieldList' => $customObject
);
4

2 回答 2

13

我不熟悉将 PHP 与 Netsuite 一起使用,但我已经完成了大量的 c#/.net Netsuite 工作。正如 Craig 所提到的,我发现使用诸如 c#/.net 之类的语言和 Visual Studio 生成的界面来找出 Netsuite SuiteTalk Web 服务 API 中可用的内容要容易得多。

NetSuite 帮助中心有大量关于这些内容的文档 - 绝不是您需要的所有内容,而是一个良好的开端。Netsuite 帮助中心

查看 SuiteFlex/SuiteTalk(Web 服务)部分,特别是此页面上的 Ids & References。 使用内部 ID、外部 ID 和引用

话虽如此,我将尝试通过 .net 示例和向销售订单添加自定义字段的说明来提供帮助。

以下是添加不同 CustomFieldRef 的几个示例:

//A list object to store all the customFieldRefs
List<CustomFieldRef> oCustomFieldRefList = new List<CustomFieldRef>();

//List or Record Type reference
SelectCustomFieldRef custbody_XXX_freight_terms = new SelectCustomFieldRef();
custbody_XXX_freight_terms.internalId = "custbody_XXX_freight_terms";
ListOrRecordRef oFreightTermsRecordRef = new ListOrRecordRef();
oFreightTermsRecordRef.internalId = <internalId of specific record in Netsuite>;
//See the References link above for more info on this - trying to figure out typeId caused me a lot of pain.
oFreightTermsRecordRef.typeId = <internalId of the List Record Type in Netsuite>; 
custbody_XXX_freight_terms.value = oFreightTermsRecordRef;
oCustomFieldRefList.Add(custbody_XXX_freight_terms);

//Freeform text sorta field            
StringCustomFieldRef objStringCustomFieldRef = new StringCustomFieldRef();
objStringCustomFieldRef.internalId = "custbody_XXX_tracking_link";
objStringCustomFieldRef.value = "StringValue";
oCustomFieldRefList.Add(objStringCustomFieldRef);

//Checkbox field type
BooleanCustomFieldRef custbody_XXX_if_fulfilled = new BooleanCustomFieldRef();
custbody_XXX_if_fulfilled.internalId = "custbody_XXX_if_fulfilled";
custbody_XXX_if_fulfilled.value = true;
oCustomFieldRefList.Add(custbody_XXX_if_fulfilled);

//By far the most complicated example a multi-select list referencing other records in Netsuite
MultiSelectCustomFieldRef custrecord_XXX_transaction_link = new MultiSelectCustomFieldRef();
//internal id of field you are updating
custrecord_XXX_transaction_link.internalId = "custrecord_XXX_transaction_link";

List<ListOrRecordRef> oListOrRecordRefList = new List<ListOrRecordRef>();

ListOrRecordRef oListOrRecordRefItemFulfillment = new ListOrRecordRef();
oListOrRecordRefItemFulfillment.name = "Item Fulfillment";
oListOrRecordRefItemFulfillment.internalId = <ItemFulfillmentInternalId>;
//Item Fulfillment is record type (Transaction -30) - this is from the above Reference links
oListOrRecordRefItemFulfillment.typeId = "-30";
oListOrRecordRefList.Add(oListOrRecordRefItemFulfillment);

ListOrRecordRef oListOrRecordRefSalesOrder = new ListOrRecordRef();
oListOrRecordRefSalesOrder.name = "Sales Order";
oListOrRecordRefSalesOrder.internalId = <SalesOrderInternalId>;
//Sales Order is record type (Transaction -30) - this is from the above Reference links
oListOrRecordRefSalesOrder.typeId = "-30";
oListOrRecordRefList.Add(oListOrRecordRefSalesOrder);

//Add array of all the ListOrRecordRefs to the MultiSelectCustomFieldRef        
custrecord_XXX_transaction_link.value = oListOrRecordRefList.ToArray();
oCustomFieldRefList.Add(custrecord_XXX_transaction_link);

//And then add all these to the Custom Record List (Array) on the Sales Order Record
objSalesOrder.customFieldList = oCustomFieldRefList.ToArray();

从我在上面的示例中可以看出,我认为您的问题出在 ListOrRecordRef typeId 上。很难从您的示例中分辨出您引用的是什么 typeId,但如果您能弄清楚这一点并在 SelectCustomFieldRef 上设置 TypeId,我认为这应该可以解决您的问题。

于 2011-02-22T16:47:18.743 回答
0

自定义字段参考内部 ID 是您尝试更新的记录上的参考 ID。这可以在 Netsuite 中该记录的事务正文字段中找到。

ListOrRecordRef 的内部 ID 是您要附加到前面提到的记录的实际列表项或记录的内部 ID

ListOrRecordRef 的 typeID 是自定义列表/记录的内部 ID。这是前一个内部 ID 的父 ID,与原始记录没有内在联系。

于 2019-01-23T22:19:08.340 回答