Netsuite获得自定义字段Java的价值

时间:2015-08-11 23:03:16

标签: java web-services soap netsuite suitetalk

我有一个SalesOrder对象,我从这样的ReadResponse中输出:

SalesOrder salesOrder = ((SalesOrder) response.getRecord());

如何在附加到SalesOrder对象的各个订单项中访问自定义字段的值?

到目前为止,我有这个,如果我需要的值是一个常规字段,它将完美地工作:

for(SalesOrderItem item: salesOrder.getItemList().getItem()){
    //etc...    
}

我还可以访问与订单项相关联的所有自定义字段的名称/内部ID,如下所示:

for(CustomFieldRef field: item.getCustomFieldList().getCustomField()){
        _console.info(field.getScriptId() + " : " + field.getInternalId());
}

如何使用这些值返回值?或者我根本不在正确的道路上?

1 个答案:

答案 0 :(得分:1)

问题是我必须将字段强制转换为适当的“自定义字段”类型才能访问“getValue()”函数。像这样:

        //loop through custom fields for custom field data.
        for(SearchColumnCustomField field: fieldArray){
            //_console.writeLn(field.getInternalId() + " " + field.getScriptId());

            //Then we are at the [Custom Field internalId: 1855].
            if (field.getInternalId().equals("1855")){
                SearchColumnStringCustomField searchBodyField = (SearchColumnStringCustomField)field;
                couponCode = searchBodyField.getSearchValue();
            }
            //Then we are at the [Custom Field internalId: 681]
            if (field.getInternalId().equals("681")){
                SearchColumnStringCustomField searchBodyField = (SearchColumnStringCustomField)field;
                orderId = searchBodyField.getSearchValue();
            }
        }