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

发布于 2024-10-11 22:02:27 字数 1255 浏览 5 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悲喜皆因你 2024-10-18 22:02:28

自定义字段引用内部 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.

囚你心 2024-10-18 22:02:27

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

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

查看 SuiteFlex/SuiteTalk(Web 服务)本页专门介绍了 Ids &参考。
使用内部 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,我认为这应该可以解决您的问题。

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:

//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();

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文