将数组映射到每个人 JSON 以便创建记录
Map the Array in to the each individual JSON so the records can be created
我正在尝试将下面的数组转换为 JSON,尝试通过遍历数组并进行转换。该数组如下所示
Quote_Sent_To__r = [
{
Quote__c=0Q02D05XGQSA2,
Id=a1H2D0m94QUAQ,
type=QuoteSentTo__c
},
{
Quote__c=0Q02D00XGQSA2,
Id=a1H2D00000AQ,
type=QuoteSentTo__c
}
]
我已将数组存储到变量 quoteSentToList 并遍历 for 循环
在每次迭代中我需要得到JSON喜欢
{
"Quote__c": "0Q02D05XGQSA2"
}
所以这可以传递给 Salesforce 更新操作。我试过
%dw 2.0
output application/json
var item = vars.quoteSentToList[counter]
---
{
"Quote__c" :payload.Id
}
说错
Reason: Unable to resolve reference of:
计数器..
Scripting language error on expression 'payload'. Reason: Unable to resolve reference of:
有效载荷..
这是我的第一个项目,非常感谢任何帮助
错误
""Unexpected character 'v' at quoteSentToList@[1:1] (line:column), expected false or true or null or {...} or [...] or number but was , while reading
quoteSentToList as Json.
1| vars.existingQuote[0].Quote_Sent_To__r ^" evaluating expression: "%dw 2.0 output application/json
---
vars.quoteSentToList map { Quote__c: payload.Id, Id: $.Id }"."
counter
是 Mule 变量,不是 DataWeave 变量。您需要使用前缀 vars.
在 DataWeave 脚本中引用它:vars.counter
.
或者,您可以一次性转换整个数组,然后根据需要使用每个元素,而不是使用 <foreach>
作用域:
%dw 2.0
output application/json
---
vars.quoteSentToList map { Quote__c: $.Id }
输出:
[
{
"Quote__c": "a1H2D0m94QUAQ"
},
{
"Quote__c": "a1H2D00000AQ"
}
]
我正在尝试将下面的数组转换为 JSON,尝试通过遍历数组并进行转换。该数组如下所示
Quote_Sent_To__r = [
{
Quote__c=0Q02D05XGQSA2,
Id=a1H2D0m94QUAQ,
type=QuoteSentTo__c
},
{
Quote__c=0Q02D00XGQSA2,
Id=a1H2D00000AQ,
type=QuoteSentTo__c
}
]
我已将数组存储到变量 quoteSentToList 并遍历 for 循环
在每次迭代中我需要得到JSON喜欢
{
"Quote__c": "0Q02D05XGQSA2"
}
所以这可以传递给 Salesforce 更新操作。我试过
%dw 2.0
output application/json
var item = vars.quoteSentToList[counter]
---
{
"Quote__c" :payload.Id
}
说错
Reason: Unable to resolve reference of:
计数器..
Scripting language error on expression 'payload'. Reason: Unable to resolve reference of:
有效载荷..
这是我的第一个项目,非常感谢任何帮助
错误
""Unexpected character 'v' at quoteSentToList@[1:1] (line:column), expected false or true or null or {...} or [...] or number but was , while reading
quoteSentToList as Json.
1| vars.existingQuote[0].Quote_Sent_To__r ^" evaluating expression: "%dw 2.0 output application/json
---
vars.quoteSentToList map { Quote__c: payload.Id, Id: $.Id }"."
counter
是 Mule 变量,不是 DataWeave 变量。您需要使用前缀 vars.
在 DataWeave 脚本中引用它:vars.counter
.
或者,您可以一次性转换整个数组,然后根据需要使用每个元素,而不是使用 <foreach>
作用域:
%dw 2.0
output application/json
---
vars.quoteSentToList map { Quote__c: $.Id }
输出:
[
{
"Quote__c": "a1H2D0m94QUAQ"
},
{
"Quote__c": "a1H2D00000AQ"
}
]