【问题标题】:Filter out decimal value in transform message in mule在 mule 中过滤掉转换消息中的十进制值
【发布时间】:2018-12-19 08:36:58
【问题描述】:

我有一个 json 有效负载,我需要在转换消息中使用过滤器过滤掉十进制值 0.00。 请找到转换消息:

%dw 1.0
%output application/java

---
payload map ((currentOptyLineItem , currentOptyLineItemIndex) -> {
    OpportunityId: currentOptyLineItem.OPPORTUNITYID,
    PricebookEntryId: currentOptyLineItem.PRICEBOOKENTRYID,
    Mix__c: currentOptyLineItem.MIX__C ,
    Product_Family__c: currentOptyLineItem.PRODUCT_FAMILY__C,
    QuoteId__c: currentOptyLineItem.QUOTEID__C as :string,
    Extended_Net_Price__c: currentOptyLineItem.EXTENDED_NET_PRICE__C,
    Recurring_Percentage__c: currentOptyLineItem.RECURRING_PERCENTAGE,
    Term__c : currentOptyLineItem.TERM,
    Product_Family_Service_Level_Recurring__c: currentOptyLineItem.ROFLAG,
    Product_with_Product_Family__c : currentOptyLineItem.BUSINESS_ENTITY__C as :string ++ "-" ++ currentOptyLineItem.SUB_BUSINESS_ENTITY__C as :string ++ "-" ++ currentOptyLineItem.PRODUCT_FAMILY__C
} filter currentOptyLineItem.MIX__C > 0
)

但我收到错误消息:

根异常堆栈跟踪: com.mulesoft.weave.mule.exception.WeaveExecutionException:异常 执行时:payload.Product_with_Product_Family__c 映射 ((referenceKey , index) -> "'" ++ referenceKey ++ "'") reduce ($$ ++ "," ++ $) ^ 'map' 运算符的类型不匹配 找到 :null, :function required :array, :function.

【问题讨论】:

  • 包含示例有效负载将是最有帮助的。
  • 请细化样本负载:
  • { "name": "xxx", "beInfo": [ { "name": "Collaboration", "subBeInfo": [ { "name": "yyy", "roDetails": [ { "roFlag": "N", "termInfo": [{ "extNetPrice": 95398.85, "term": 12 }] } ] } ] } ] },
  • 嗨,您指定的输入与您的脚本不匹配的两件事,也不是错误。现在根据错误消息,您的 mule 代码中的某处似乎有一个表达式 payload.Product_with_Product_Family__c map ... 并且 Product_withProduct_Family__c 为 null 您可以使用 payload.Product_with_Product_Family__c default [] map ... 轻松解决此问题
  • 如上文所述,请提供正确的输入负载。虽然你可以试试这个。

标签: json dataweave mule-esb


【解决方案1】:

如果你想要不带小数,请试试这个:

Extended_Net_Price__c: currentOptyLineItem.EXTENDED_NET_PRICE__C as :string {format: "#.#####"}

否则对于小数位数可以实现为:

Extended_Net_Price__c: currentOptyLineItem.EXTENDED_NET_PRICE__C as :number {format: '#.#####'} 

【讨论】:

  • 我需要过滤这个字段 Mix__c: currentOptyLineItem.MIX__C 因为它从有效负载中接收 0.00 %...所以请告诉我如何在转换消息中使用这个过滤选项。
猜你喜欢
  • 2021-09-08
  • 1970-01-01
  • 1970-01-01
  • 2019-05-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-30
  • 2023-01-16
相关资源
最近更新 更多