I need to append the data from responseLicensing (like expiryDate, cloudAccountName, cloudAccountId) to the responseSfdc data depending on the similar 'key' value.
Perform a lookup in the responseLicensing object using the key in an instance of responseSfdc and append some key-value pairs picked as a result of a successful lookup, to responseSfdc object.
%dw 2.0
output application/json
var responseSfdc = [{
"key": "SUBT00009925-1",
"contractEndDate": null,
"product": {
"productName": "ArtPro+ Subscription",
"productCode": "ArtPro+S",
"downloadURL": null,
"upgradeProduct": null
},
"projectReference": null,
"orderNumber": "O-0000001105",
"orderCreationDate": "2020-07-14T07:48:04.000Z",
"subscriptionName": null,
"autoRenewal": null
},
{
"key": "SUBT00009925-2",
"contractEndDate": null,
"product": {
"productName": "ArtPro+ Subscription",
"productCode": "ArtPro+S",
"downloadURL": null,
"upgradeProduct": null
},
"projectReference": null,
"orderNumber": "O-0000001105",
"orderCreationDate": "2020-07-14T07:48:04.000Z",
"subscriptionName": null,
"autoRenewal": null
}]
var responseLicensing = [{
"key": "SUBT00009925-1",
"expiryDate": "2021-01-16"
},
{
"key": "SUBT00009925-2",
"expiryDate": "2021-01-16",
"cloudPublicName": "dodp-testcloud",
"cloudAccountId": "a-t-1000-5001-0687-0024"
}]
---
{
responseSfdc map (sfdc,i) -> {
}
}
Output I need is something like this -
[{
"key": "SUBT00009925-1",
"contractEndDate": null,
"product": {
"productName": "ArtPro+ Subscription",
"productCode": "ArtPro+S",
"downloadURL": null,
"upgradeProduct": null
},
"projectReference": null,
"orderNumber": "O-0000001105",
"orderCreationDate": "2020-07-14T07:48:04.000Z",
"subscriptionName": null,
"autoRenewal": null,
"expiryDate": "2021-01-16"
},
{
"key": "SUBT00009925-2",
"contractEndDate": null,
"product": {
"productName": "ArtPro+ Subscription",
"productCode": "ArtPro+S",
"downloadURL": null,
"upgradeProduct": null
},
"projectReference": null,
"orderNumber": "O-0000001105",
"orderCreationDate": "2020-07-14T07:48:04.000Z",
"subscriptionName": null,
"autoRenewal": null,
"expiryDate": "2021-01-16",
"cloudPublicName": "dodp-testcloud",
"cloudAccountId": "a-t-1000-5001-0687-0024"
}]
responseSfdcwith the ones fromresponseLicensingfor elements that match the exactkey? - aled