我正在使用 Mulesoft 将记录从 SFTP 集成到 Salesforce(upsert)。在 SFTP 记录中,日期字段 (Store_Close_Date__c) 有时为空。这在 Mulesoft 中生成了 java 异常,因此我编辑了 config.xml 文件以转换该字段。
请在下面找到 config.xml
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc" xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/sfdc http://www.mulesoft.org/schema/mule/sfdc/current/mule-sfdc.xsd
http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
<sfdc:config name="UpsertProducts" username="xxxx" password="xxxx" securityToken="xxxx" url="https://xxxx.my.salesforce.com/services/Soap/u/37.0" doc:name="SFTP_Products"/>
<sftp:connector name="SFTP_Products" validateConnections="true" autoDelete="false" doc:name="SFTP_Products">
<service-overrides messageReceiver="chalhoub.ChalhoubSftpMessageReceiverProducts"/>
</sftp:connector>
<sftp:endpoint exchange-pattern="request-response" host="localhost" port="22" name="SFTP" responseTimeout="10000" doc:name="SFTP"/>
<sftp:connector name="SFTP_Locations" validateConnections="true" autoDelete="false" doc:name="SFTP_Locations">
<service-overrides messageReceiver="chalhoub.ChalhoubSftpMessageReceiverLocations"/>
</sftp:connector>
<sfdc:config name="UpsertLocations" username="xxxx" password="xxxx" securityToken="xxxx" url="https://xxxx.my.salesforce.com/services/Soap/u/37.0" doc:name="SFTP_Locations"/>
<flow name="Products">
<sftp:inbound-endpoint connector-ref="SFTP_Products" host="xxxx" port="xxxx" path="//" user="xxxx" password="xxxx" responseTimeout="60000" autoDelete="false" doc:name="Get Products"/>
<message-chunk-splitter messageSize="1000000" doc:name="Products Chunk Splitter"/>
<dw:transform-message doc:name="Products Transform Message" metadata:id="007db759-7ccf-44fd-b053-0a67709fd56b" ><!-- metadata:id="a9bd1fde-189a-40e7-aed1-85652885c03f" -->
<dw:input-payload mimeType="application/csv"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload map ((payload01 , indexOfPayload01) -> {
Name: payload01.ITEM_DESC,
Product_Number__c: payload01.ITEM_NUMBER,
Primary_VPN__c: payload01.PRIMARY_VPN,
Department_ID__c: payload01.DEPARTMENT_ID,
Department_Name__c: payload01.DEPARTMENT_NAME,
Class_ID__c: payload01.CLASS_ID,
SubClass_ID__c: payload01.SUBCLASS_ID,
SubClass_Name__c: payload01.SUBCLASS_NAME,
Department_Brand__c: payload01.DEPARTMENT_BRAND,
Gender__c: payload01.GENDER,
Season__c: payload01.SEASON,
Size__c: payload01.SIZE,
Color__c: payload01.COLOR,
Line__c: payload01.LINE,
Sub_Line__c: payload01."SUB LINE",
Supplier_Class__c: payload01."SUPPLIER CLASS",
Supplier_SubClass__c: payload01."SUPPLIER SUBCLASS"
})]]></dw:set-payload>
</dw:transform-message>
<sfdc:upsert-bulk config-ref="UpsertProducts" type="Product__c" externalIdFieldName="Product_Number__c" doc:name="Upsert Products ">
<sfdc:objects ref="#[payload]"/>
</sfdc:upsert-bulk>
</flow>
<flow name="Locations">
<sftp:inbound-endpoint connector-ref="SFTP_Locations" host="xxxx" port="xxxx" path="//" user="xxxx" password="xxxx" responseTimeout="60000" autoDelete="false" doc:name="Get Locations"/>
<message-chunk-splitter messageSize="1000000" doc:name="Locations Chunk Splitter"/>
<dw:transform-message doc:name="Locations Transform Message" metadata:id="a61e8266-246f-4cae-a372-f5fbc641e5c8">
<dw:input-payload mimeType="application/csv"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload map ((payload01 , indexOfPayload01) -> {
Name: payload01.STORE_NAME,
Location_Code__c: payload01.STORE,
Location_Open_Date__c: payload01.STORE_OPEN_DATE as :date{format:"dd.MM.yyyy"} default 'null',
Store_Close_Date__c: payload01.STORE_CLOSE_DATE as :date{format:"dd.MM.yyyy"} default 'null',
Mall_Name__c: payload01.MALL_NAME,
Currency_Code__c: payload01.CURRENCY_CODE,
Country_ID__c: payload01.COUNTRY_ID,
Country_Description__c: payload01.COUNTRY_DESC,
Org_Unit_ID__c: payload01.ORG_UNIT_ID,
Org_Unit_Description__c: payload01.DESCRIPTION
})]]></dw:set-payload>
</dw:transform-message>
<sfdc:upsert-bulk config-ref="UpsertLocations" type="Location__c" externalIdFieldName="Location_Code__c" doc:name="Upsert Locations">
<sfdc:objects ref="#[payload]"/>
</sfdc:upsert-bulk>
</flow>
</mule>
现在的问题是,只有没有 Store_Close_Date__c = null 的记录被更新插入 Salesforce。这可能来自我对 config.xml 文件所做的修改。
所有记录,包括 Store_Close_Date__c = null 的记录都应该被更新。
请指教 谢谢