C# NetSuite WebServices: Get value from custom field in saved search (ItemSearchAdvanced)

后端 未结 2 1491
南旧
南旧 2021-01-23 15:18

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 w

相关标签:
2条回答
  • 2021-01-23 16:00

    You would need to loop over the CustomRecord items in the customFieldList. I then usually check for a specific type so I can cast to the correct object, but with some reflection you could probably avoid that.

    foreach (Record r in mySearchResponse.recordList){
      foreach (CustomFieldRef cr in ((CustomRecord)r).customFieldList){
        if (cr.GetType().Name == "SelectCustomFieldRef"){
          if (((SelectCustomFieldRef)cr).scriptId == "my_custom_field"){
            internalID = ((CustomRecord)r).internalId;
          }
        }
      }
    }
    
    0 讨论(0)
  • 2021-01-23 16:17

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

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

    0 讨论(0)
提交回复
热议问题