3

我有一个从 ReadResponse 投射的 SalesOrder 对象,如下所示:

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

我如何使用这些来返回值?还是我根本就没有走对路?

4

1 回答 1

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();
            }
        }
于 2015-08-14T23:08:56.767 回答