我正在尝试访问MULESOFT流中的父“记录ID”(自动生成的ID),并将其存储到SalesForce的子表中,并将该记录ID存储在一个变量中,然后通过DataWeave Transformation将其传递给子表。我正在为此任务使用一个流程。谁能告诉我如何获取父表记录ID?谢谢。
这是我的流程Confi。 XML文件
<flow name="shoppingcartpocmcpostsfuserFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/customeruser" allowedMethods="POST" doc:name="HTTP"/>
<object-to-byte-array-transformer doc:name="Object to Byte Array"/>
<dw:transform-message doc:name="Transform Message" metadata:id="4851f81e-2a1b-4e5e-a34f-cc328e6dd23d">
<dw:input-payload mimeType="application/json"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
[{
Name: payload.ShoppingCartUser.ShoppingCartUserName,
FirstName__c: payload.ShoppingCartUser.FirstName,
LastName__c: payload.ShoppingCartUser.LastName,
EmailID__c: payload.ShoppingCartUser.EmailID,
PhoneNumber__c: payload.ShoppingCartUser.PhoneNumber,
CompanyName__c: payload.ShoppingCartUser.Company,
CustomerType__c: payload.ShoppingCartUser.Customer_Type
}]]]></dw:set-payload>
</dw:transform-message>
<sfdc:create config-ref="Salesforce__Basic_Authentication" type="MS_ShoppingCartUser__c" doc:name="Salesforce Connector for User Details">
<sfdc:objects ref="#[payload]"/>
</sfdc:create>
<object-to-string-transformer doc:name="Object to String"/>
<set-variable variableName="id" value="#[flowVars.id]" doc:name="Variable"/>
<dw:transform-message doc:name="Transform Message for User Address" metadata:id="4851f81e-2a1b-4e5e-a34f-cc328e6dd23d">
<dw:input-payload mimeType="application/json"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
[{
AddressLine1__c: payload.ShoppingCartUser.AddressLine_1,
AddressLine2__c: payload.ShoppingCartUser.AddressLine_2,
CountyName__c: payload.ShoppingCartUser.County,
City__c: payload.ShoppingCartUser.City,
Country__c: payload.ShoppingCartUser.Country,
State__c: payload.ShoppingCartUser.State,
ZipCode__c: payload.ShoppingCartUser.Zipcode,
EmailID__c: id
}]]]></dw:set-payload>
</dw:transform-message>
<sfdc:create config-ref="Salesforce__Basic_Authentication" type="MS_ShoppingCart__c" doc:name="Salesforce Connector for User Address">
<sfdc:objects ref="#[payload]"/>
</sfdc:create>
<object-to-string-transformer doc:name="Object to String"/>
</flow>
答案 0 :(得分:0)
sfdc:create
操作将返回“结果” https://docs.mulesoft.com/connectors/salesforce/salesforce-connector-reference-96#Result
它具有一个“ Id”字段。您可以使用“ payload.Id”
访问ID请注意,在您的示例中,您将需要删除对象到字符串才能访问它。它还会覆盖您的有效负载。因此,如果在第二次转换中需要相同的有效载荷值,则需要使用增强器。