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
);
答案 0 :(得分:11)
我不熟悉使用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。很难从你的例子中看出你引用的是什么类型,但如果你能解决这个问题并在SelectCustomFieldRef上设置TypeId,我认为应该解决你的问题。
答案 1 :(得分:0)
“自定义字段引用内部ID”是您要更新的记录上的引用ID。可以在Netsuite中该记录的“交易主体”字段中找到。
ListOrRecordRef的内部ID是您要附加到上述记录的实际列表项或记录的内部ID
ListOrRecordRef的typeID是自定义列表/记录的内部ID。这是上一个内部ID的父ID,并不是固有地与原始记录相关联。