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,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
);
The documentation for Netsuite is quite lacking, they cover the basics and then let you loose to explore. Anyone without a vast knowledge of PHP trying to use their php toolkit would be on their knees begging for mercy.
At any point throughout this whole project it's been trail and error and trying to make sense out of everything until stuff started to work.
I'm stumped on assigning custom fields to sales orders, I know it has to be an object of an object of an object in order for it to tier down the xml for the soap to take over but what with what with what?
I have some code I worked that is getting somewhere but it is complaining it's not the right RecordRef type. If anyone worked with Netsuite and feels my pain please lend me your knowledge before I pull out all my hair.
Thanks in advance.
Code:
$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
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
自定义字段引用内部 ID 是您尝试更新的记录上的引用 ID。这可以在 Netsuite 内该记录的交易正文字段中找到。
ListOrRecordRef 的内部 ID 是要附加到前面提到的记录的实际列表项或记录的内部 ID
ListOrRecordRef 的 typeID 是自定义列表/记录的内部 ID。这是先前内部 ID 的父 ID,并且与原始记录没有内在联系。
The Custom Field Ref Internal ID is the reference ID on the record you are trying to update. This can be found in the Transaction Body fields for that record within Netsuite.
The Internal ID for the ListOrRecordRef is the internal ID for the actual list item or record that you want to attach to the previously mentioned record
The typeID for the ListOrRecordRef is the internal ID for the custom list/record. This is the parent ID for the previous internal ID, and is not inherently tied to the original record.
我不熟悉将 PHP 与 Netsuite 结合使用,但我已经完成了大量的 c#/.net Netsuite 工作。正如 Craig 提到的,我发现使用 c#/.net 等语言和 Visual Studio 生成的界面来了解 Netsuite SuiteTalk Web 服务 API 中可用的内容要容易得多。
NetSuite 帮助中心中有大量有关这些内容的文档 - 绝不是您需要的所有内容,只是一个好的开始。 Netsuite 帮助中心
查看 SuiteFlex/SuiteTalk(Web 服务)本页专门介绍了 Ids &参考。
使用内部 ID、外部 ID、和参考文献
话虽如此,我将尝试通过 .net 示例和参考资料来提供帮助。向销售订单添加自定义字段的说明。
以下是添加不同 CustomFieldRef 的几个示例:
从上面的示例中我可以看出,我认为您的问题在于 ListOrRecordRef typeId。很难从您的示例中判断您正在引用什么 typeId,但如果您可以弄清楚并在 SelectCustomFieldRef 上设置 TypeId,我认为这应该可以解决您的问题。
I am not familiar using PHP with Netsuite but I have done a good amount of c#/.net Netsuite work. As Craig mentioned I find it much easier using a language such c#/.net with a Visual Studio generated interface to figure out what is available in the Netsuite SuiteTalk web service API.
There is a fair amount of documentation around this stuff in the NetSuite Help Center - by no means everythign you will need but a good start. Netsuite Help Center
Check out the SuiteFlex/SuiteTalk (Web Services) section specifically this page on Ids & References.
Using Internal Ids, External Ids, and References
With that said I will try to help with a .net example & explanation of adding a custom field to a Sales Order.
Here are a few examples of adding different CustomFieldRefs:
From what I can tell in your above example I think your issue is with the ListOrRecordRef typeId. Its hard to tell from your example what typeId you are referencing but if you can figure that out and set the TypeId on your SelectCustomFieldRef I think that should fix your issue.