php – Netsuite:如何将自定义字段附加到销售订单

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,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
);
我不熟悉使用PHP和Netsuite,但我已经完成了大量的c#/.net Netsuite工作.正如Craig所提到的,我发现使用像Visual Studio生成的界面这样的c#/ .net这样的语言可以更容易地找出Netsuite SuiteTalk Web服务API中可用的内容.

NetSuite帮助中心提供了大量关于这些内容的文档 – 绝不是每个人都需要的,而是一个良好的开端. Netsuite Help Center

在Ids& amp;上查看SuiteFlex / SuiteTalk(Web服务)部分.引用.
Using Internal Ids,External Ids,and References

有了这个说我会尝试帮助.net示例&将自定义字段添加到销售订单的说明.

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

//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,我认为应该解决你的问题.

相关文章

Hessian开源的远程通讯,采用二进制 RPC的协议,基于 HTTP 传输。可以实现PHP调用Java,Python,C#等多语...
初识Mongodb的一些总结,在Mac Os X下真实搭建mongodb环境,以及分享个Mongodb管理工具,学习期间一些总结...
边看边操作,这样才能记得牢,实践是检验真理的唯一标准.光看不练假把式,光练不看傻把式,边看边练真把式....
在php中,结果输出一共有两种方式:echo和print,下面将对两种方式做一个比较。 echo与print的区别: (...
在安装好wampServer后,一直没有使用phpMyAdmin,今天用了一下,phpMyAdmin显示错误:The mbstring exte...
变量是用于存储数据的容器,与代数相似,可以给变量赋予某个确定的值(例如:$x=3)或者是赋予其它的变...