简体   繁体   English

从 Netsuite 访问值 hash,枚举器

[英]Access value from a Netsuite hash, Enumerator

Hi I am trying to extract a value from a Netsuite hash inside custom fields, and some others, which typically look like this - `嗨,我正在尝试从自定义字段和其他一些字段中的 Netsuite hash 中提取一个值,通常看起来像这样 - `

"custbody_delivery_ticket_number"=>
 {
 "script_id"=>"custbody_delivery_ticket_number", 
 "internal_id"=>"2701", 
 "type"=>"platformCore:DateCustomFieldRef", 
 "attributes"=> {
 "value"=>"123abc"
 }

}` and want the value of it inside of attributes. }` 并希望它的值在属性中。

Have tried many different ways, but one in particular -尝试了许多不同的方法,但特别是一种 -

 delivery_ticket_number: "#{netsuite_sales_orders.custom_field_list.custom_fields.select['custbody_nef_meter_ticket_number']['attributes']['value']}", 

throws error for class Enumerator, NoMethodError: undefined method `[]' for #Enumerator:0x00005589ec778730 which indicates may be getting close, but doing something wrong.为 class 枚举器抛出错误,NoMethodError:#Enumerator:0x00005589ec778730 的未定义方法“[]”表明可能正在接近,但做错了什么。

If anyone has any idea how to get values from these kind of hashes?如果有人知道如何从这些哈希中获取值?

(Am told by the system admin that it is the correct custbody identifier) (系统管理员告诉我这是正确的保管人标识符)

Many Thanks非常感谢

Eventually fixed this, grabbing Netsuite custom fields with a select of script_id by name,and map as below:最终解决了这个问题,通过名称获取 select 的 script_id 和 map 的 Netsuite 自定义字段,如下所示:

delivery_date.netsuite_sales_order.custom_fields_list.custom_fields.select { |field| delivery_date.netsuite_sales_order.custom_fields_list.custom_fields.select { |字段| field.script_id == 'custbody_delivery_date' }.map { |field| field.script_id == 'custbody_delivery_date' }.map { |field| field.value }.first field.value }.first

First selecting the script_id by unique name, then mapping to the value.首先通过唯一名称选择 script_id,然后映射到值。 Was able to get any custom field like this, preferable as they can move and might not have the same index if use an index to grab them, fetching an incorrect value.能够获得任何这样的自定义字段,更可取,因为它们可以移动,并且如果使用索引来获取它们,则可能没有相同的索引,从而获取不正确的值。 This way ensures getting the correct data even if the item is moved up or down in the custom fields list.即使项目在自定义字段列表中向上或向下移动,这种方式也能确保获得正确的数据。

Thanks for everyones help!感谢大家的帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM