简体   繁体   中英

XML mapping to salesforce using Dataweave

I am trying to map the data from xml (input file) to developer salesforce version.

input file:

<Z0DEBMAS>    
    <E1KNA1M SEGMENT="1">    
    <KUNNR>0030003926</KUNNR>    
    <NAME1>SAMS CLUB #6493</NAME1>    
    <VKORG>4571</VKORG>    
    </E1KNA1M>       
</Z0DEBMAS>

Dataweave Code in Mule:

<dw:transform-message doc:name="Transform XML to sfdc">
    <dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload.Z0DEBMAS.*E1KNA1M map {
    AccountNumber: $.KUNNR,
    Name: $.NAME1,
    Sales_Organization__c: $.VKORG
    }]]></dw:set-payload>    
</dw:transform-message>

I am getting output for only the entry KUNNR and NAME1 but not for VKORG , I am getting null values for VKORG as shown below.

Output in Mule Console:

INFO  2016-08-25 12:30:06,169 [[xmltosfdc_realtime].xmltosfdc_realtimeFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor: **[{AccountNumber=0030003926, Name=SAMS CLUB #6493, *Sales_Organization__c=null*}]**
INFO  2016-08-25 12:30:09,467 [[xmltosfdc_realtime].xmltosfdc_realtimeFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor: [[SaveResult  errors='{[0]}'
 id='0012800000poeQRAAY'
 success='true'

销售人员的产出

Below are the datatype of the fields to be mapped in salesforce :

数据类型

Please let me know if anyone can help me in this.

Apparently the Sales Organization was not mapped due to different data type. If refer to the expected datatype , it should be a Number/Numeric.

Incorrectly, the result of your transformation from DataWeave is a String. Therefore, I suggest you to convert it to Number first eg: Sales_Organization__c: $.VKORG as :number as Integer or Sales_Organization__c: $.VKORG as :number {class: "java.math.BigDecimal"} as BigDecimal

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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