DataWeave未贴图的映射
在为此Salesforce有效载荷编写数据驱动时需要一些帮助。
请帮助为此输入和预期输出创建数据启示。
输入
[
{
"Order": {
"Account_Name__c": "test danish 002",
"Id": "8018s000004mpqjAAA",
"type": "Order"
},
"UnitPrice": "13.45",
"Product2": {
"Id": null,
"type": "Product2",
"Name": "* 1 LEG FOR MESAHORNO STAND110"
},
"Id": "8028s000000kyUDAAY",
"type": "OrderItem",
"OrderItemNumber": "0000051590"
},
{
"Order": {
"Account_Name__c": "test danish 002",
"Id": "8018s000004mpqjAAA",
"type": "Order"
},
"UnitPrice": "308.45",
"Product2": {
"Id": null,
"type": "Product2",
"Name": "* 2 Uprights incl castors f RTWZ 600 Var"
},
"Id": "8028s000000kyUEAAY",
"type": "OrderItem",
"OrderItemNumber": "0000051591"
},
{
"Order": {
"Account_Name__c": "test danish 002",
"Id": "8018s000004mpqjAAA",
"type": "Order"
},
"UnitPrice": "31.0",
"Product2": {
"Id": null,
"type": "Product2",
"Name": "* 25 Comp Glass Rack - 3 Ext - Red Base"
},
"Id": "8028s000000kyUFAAY",
"type": "OrderItem",
"OrderItemNumber": "0000051592"
},
{
"Order": {
"Account_Name__c": "test danish 002",
"Id": "8018s000004mpqjAAA",
"type": "Order"
},
"UnitPrice": "31.65",
"Product2": {
"Id": null,
"type": "Product2",
"Name": "* 36 Comp Glass Rack 3 Ext - Gray"
},
"Id": "8028s000000kyUGAAY",
"type": "OrderItem",
"OrderItemNumber": "0000051593"
}
]
这是OrderLineItems上的Salesforce查询 输出看起来像
输出
{
"Id":"8018s000004mpqjAAA",
"Order Name": "test danish 002",
"Line Items": [
{
"Id":"8028s000000kyUDAAY",
"ItemNumber":"0000051590",
"Name":"* 1 LEG FOR MESAHORNO STAND110"
},
{
"Id":"8028s000000kyUEAAY",
"ItemNumber":"0000051591",
"Name":"* 2 Uprights incl castors f RTWZ 600 Var"
},
{
"Id":"8028s000000kyUFAAY",
"ItemNumber":"0000051592",
"Name":"* 25 Comp Glass Rack - 3 Ext - Red Base"
},
{
"Id":"8028s000000kyUGAAY",
"ItemNumber":"0000051593",
"Name":"* 36 Comp Glass Rack 3 Ext - Gray"
}
]
}
Need some help in writing DataWeave for this Salesforce payload.
Please help with creating a DataWeave for this input and expected output.
INPUT
[
{
"Order": {
"Account_Name__c": "test danish 002",
"Id": "8018s000004mpqjAAA",
"type": "Order"
},
"UnitPrice": "13.45",
"Product2": {
"Id": null,
"type": "Product2",
"Name": "* 1 LEG FOR MESAHORNO STAND110"
},
"Id": "8028s000000kyUDAAY",
"type": "OrderItem",
"OrderItemNumber": "0000051590"
},
{
"Order": {
"Account_Name__c": "test danish 002",
"Id": "8018s000004mpqjAAA",
"type": "Order"
},
"UnitPrice": "308.45",
"Product2": {
"Id": null,
"type": "Product2",
"Name": "* 2 Uprights incl castors f RTWZ 600 Var"
},
"Id": "8028s000000kyUEAAY",
"type": "OrderItem",
"OrderItemNumber": "0000051591"
},
{
"Order": {
"Account_Name__c": "test danish 002",
"Id": "8018s000004mpqjAAA",
"type": "Order"
},
"UnitPrice": "31.0",
"Product2": {
"Id": null,
"type": "Product2",
"Name": "* 25 Comp Glass Rack - 3 Ext - Red Base"
},
"Id": "8028s000000kyUFAAY",
"type": "OrderItem",
"OrderItemNumber": "0000051592"
},
{
"Order": {
"Account_Name__c": "test danish 002",
"Id": "8018s000004mpqjAAA",
"type": "Order"
},
"UnitPrice": "31.65",
"Product2": {
"Id": null,
"type": "Product2",
"Name": "* 36 Comp Glass Rack 3 Ext - Gray"
},
"Id": "8028s000000kyUGAAY",
"type": "OrderItem",
"OrderItemNumber": "0000051593"
}
]
This is the Salesforce Query on OrderLineItems but the transformed payload needs to be done on Order Object
and the output would look like
Output
{
"Id":"8018s000004mpqjAAA",
"Order Name": "test danish 002",
"Line Items": [
{
"Id":"8028s000000kyUDAAY",
"ItemNumber":"0000051590",
"Name":"* 1 LEG FOR MESAHORNO STAND110"
},
{
"Id":"8028s000000kyUEAAY",
"ItemNumber":"0000051591",
"Name":"* 2 Uprights incl castors f RTWZ 600 Var"
},
{
"Id":"8028s000000kyUFAAY",
"ItemNumber":"0000051592",
"Name":"* 25 Comp Glass Rack - 3 Ext - Red Base"
},
{
"Id":"8028s000000kyUGAAY",
"ItemNumber":"0000051593",
"Name":"* 36 Comp Glass Rack 3 Ext - Gray"
}
]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设所有订单ID都是相同的,则可以直接从有效载荷中映射
ID
,然后使用MAP
on有效载荷
获取行项目
Assuming that all the order IDs are same you can just map the
Id
directly from payload and use themap
onpayload
to get theLine Items
这样尝试:
Try like this:
这是您在订购ID时可以尝试的另一种选择,
Here is one more option that you can try when ordered Id's are not the same