Member since
04-15-2024
2
Posts
1
Kudos Received
0
Solutions
04-17-2024
03:23 AM
1 Kudo
Hi @nidhipal Looks like you figured this out here, https://community.cloudera.com/t5/Support-Questions/Possible-RecordPath-to-fetch-data-from-a-list-based-on-a/m-p/386665/highlight/true#M246104 The added RecordPath works. ../goodIdentifications[*][./goodIdentificationTypeId = "SKU"]/idValue Thank you!
... View more
04-16-2024
12:05 PM
Hi Everyone, I am trying to perform some data transformations using UpdateRecord processor. The input format is a nested JSON, and I am able to perform shifting of some fields using RecordPath. But facing issues when preparing a field using some conditional logic from a nested list. Here is my scenario: Input JSON [
{
"orderId": "1234",
"orderName": "Order 1",
"orderItems": [
{
"orderItemSeqId": "01",
"itemStatusId": "ITEM_APPROVED",
"orderItemQuantity": 1,
"unitPrice": 149,
"goodIdentifications": [
{
"goodIdentificationTypeId": "SHOPIFY_PROD_ID",
"idValue": "43623074824370"
},
{
"goodIdentificationTypeId": "SKU",
"idValue": "2510524-4BB-S"
},
{
"goodIdentificationTypeId": "UPCA",
"idValue": "2510524-4BB-S"
}
]
},
{
"orderItemSeqId": "02",
"itemStatusId": "ITEM_APPROVED",
"orderItemQuantity": 1,
"unitPrice": 159,
"goodIdentifications": [
{
"goodIdentificationTypeId": "SHOPIFY_PROD_ID",
"idValue": "43623074824370"
},
{
"goodIdentificationTypeId": "SKU",
"idValue": "2510524-4BB-S"
},
{
"goodIdentificationTypeId": "UPCA",
"idValue": "2510524-4BB-S"
}
]
}
]
}
] The output expected is below: - New field "itemSku" should be added to each object of orderItems list which is fetched from the goodIdentifications list with goodIdentificationTypeId as SKU. Expected Output JSON [
{
"orderId": "1234",
"orderName": "Order 1",
"orderItems": [
{
"orderItemSeqId": "01",
"itemStatusId": "ITEM_APPROVED",
"orderItemQuantity": 1,
"unitPrice": 149,
"goodIdentifications": [
{
"goodIdentificationTypeId": "SHOPIFY_PROD_ID",
"idValue": "43623074824370"
},
{
"goodIdentificationTypeId": "SKU",
"idValue": "2510524-4BB-S"
},
{
"goodIdentificationTypeId": "UPCA",
"idValue": "2510524-4BB-S"
}
],
"itemSku": "2510524-4BB-S"
},
{
"orderItemSeqId": "02",
"itemStatusId": "ITEM_APPROVED",
"orderItemQuantity": 1,
"unitPrice": 159,
"goodIdentifications": [
{
"goodIdentificationTypeId": "SHOPIFY_PROD_ID",
"idValue": "43623074824371"
},
{
"goodIdentificationTypeId": "SKU",
"idValue": "2510524-4BB-T"
},
{
"goodIdentificationTypeId": "UPCA",
"idValue": "2510524-4BB-T"
}
],
"itemSku": "2510524-4BB-T"
}
]
}
] I would like to know if performing such conditional logic is possible and what could be the possible RecordPath to prepare this field?? Tried something like, Added new property in UpdateRecord. Property - /orderItems[*]/itemSku Value - ../goodIdentifications[./goodIdentificationTypeId = ‘’SKU"]/idValue But this doesnt seem to work. Any help would be appreciated. Thank you.
... View more
Labels:
- Labels:
-
Apache NiFi