【发布时间】:2020-10-29 05:03:27
【问题描述】:
如何在 Dataweave 2.0 中使用 IF ELSE 条件?我正在尝试围绕其中一个有效负载数据元素做一个条件,但是当我执行它时它会抛出错误。
Unable to resolve reference of method
Unable to resolve reference of attribute
我错过了什么吗?
XML >
<payments>
<payment>
<custom-method>
<method-name>AdyenComponent</method-name>
<custom-attributes>
<custom-attribute attribute-id="adyenPaymentMethod">iDEAL</custom-attribute>
</custom-attributes>
</custom-method>
<amount>145.99</amount>
<processor-id>Adyen_Component</processor-id>
<transaction-id>851603387831889A</transaction-id>
<custom-attributes>
<custom-attribute attribute-id="Adyen_log"></custom-attribute>
<custom-attribute attribute-id="authCode">Authorised</custom-attribute>
</custom-attributes>
</payment>
</payments>
数据编织代码
%dw 2.0
output application/json
ns ns0 http://www.demandware.com/xml/impex/order/2006-10-31
---
[{
Ascent_FPL__Payment_Method__c : if ((payload.order.payments.payment.custom-method.custom-attributes.*custom-attribute filter(item) -> (item.@"attribute-id" == "adyenPaymentMethod")) [0] =="iDEAL") "iDEAL" else (payload.ns0#order.ns0#"custom-attributes".*ns0#"custom-attribute" filter(item) -> (item.@"attribute-id" == "creditCardType")) [0]
}]
【问题讨论】: