C#NetSuite WebServices:从已保存的搜索中的自定义字段中获取值(ItemSearchAdvanced) [英] C# NetSuite WebServices: Get value from custom field in saved search (ItemSearchAdvanced)

查看:91
本文介绍了C#NetSuite WebServices:从已保存的搜索中的自定义字段中获取值(ItemSearchAdvanced)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#MVC通过其WebServices API连接到NetSuite.我有一些当前代码,该代码调用保存的库存项目搜索.这是当前运行良好的代码:

I'm using C# MVC to connect to NetSuite using their WebServices API. I have some current code that calls a saved search of inventory items. Here is the current code that is working perfectly:

ItemSearchAdvanced searchItems = new ItemSearchAdvanced();
searchItems.savedSearchId = "128";
SearchResult result = netSuiteSvc.search(searchItems);
int totalRecords = 0;
int processedRecords = 0;

UpdateNetsuitePriceListModel returnObj = new UpdateNetsuitePriceListModel();
returnObj.NewPriceList = new List<NetSuitePriceListRecord>();
if (result.status.isSuccess)
{
    SearchRow[] searchRows = result.searchRowList;
    if (searchRows != null && searchRows.Length >= 1)
    {
        for (int i = 0; i < searchRows.Length - 1; i++)
        {
            ItemSearchRow itemRow = (ItemSearchRow)searchRows[i];
            if (itemRow.basic.itemId != null && itemRow.basic.mpn != null && itemRow.basic.basePrice != null && itemRow.basic.salesDescription != null)
            {
                returnObj.NewPriceList.Add(new NetSuitePriceListRecord()
                {
                    ItemId = itemRow.basic.itemId[0].searchValue,
                    ManufacturerPartNumber = itemRow.basic.mpn[0].searchValue,
                    ContractPrice = Convert.ToDecimal(itemRow.basic.basePrice[0].searchValue),
                    Cost = CalculateProductCostForIngram(Convert.ToDecimal(itemRow.basic.basePrice[0].searchValue)),
                    Description = itemRow.basic.salesDescription[0].searchValue
                });
                processedRecords++;
            }
            totalRecords++;
        }
    }
    else
    {
        throw new Exception("NetSuite Part List Blank");
    }
}
else
{
    throw new Exception("NetSuite Part List Search Failure");
}

现在,我需要从自定义添加的字段中拉出itemId,而不是从默认的itemId字段中拉出.

Now I have need to pull the itemId from a custom added field rather than the default itemId field.

很显然,由于这是一个自定义字段,因此它不是ItemSearchRowBasic的属性.看起来代替属性,我可以选择"customFieldList",它是"SearchColumnCustomField"的数组.如果选择数组的索引,则可以看到SearchColumnCustomField包含:

Obviously since this is a custom field it isn't a property of ItemSearchRowBasic. It looks like instead of the property I can choose "customFieldList" which is an array of "SearchColumnCustomField". If I choose an index for the array I can see that SearchColumnCustomField contains:

  • customLabel
  • internalId
  • scriptId

我想我应该能够获取SearchColumnCustomField的internalId并以某种方式使用它来获取该自定义列的搜索值,但是我很难找到到目前为止适合的任何示例.

I imagine I should be able to get the internalId of the SearchColumnCustomField and somehow use that to get the search value for that custom column but I've had some trouble finding any examples that fit so far.

此自定义字段是添加到所有库存项目的自由格式文本字段.

This custom field is a free form text field added to all inventory items.

推荐答案

尝试使用字段ID("custitem_xyz")设置scriptId.那应该工作.

Try setting scriptId with the ID of the field ("custitem_xyz"). That should work.

在2013年之前,人们会使用internalId,但是从那以后,它改成了scriptId.

Before 2013 one would use internalId, but since then it changed to scriptId.

这篇关于C#NetSuite WebServices:从已保存的搜索中的自定义字段中获取值(ItemSearchAdvanced)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆