Forum Discussion
Hi koryknick ,
My bad, please find below a simplified version of same:
Input:
{
"project": {
"projectId": 2
},
"items": [
{
"description": "Architecture Fees",
"unitPrice": "1000",
"projectActivity": {
"chartCodes": [
{
"chartCode": {
"uniqueCode": "7845",
"supplementalType": "BOMA"
}
}
]
}
},
{
"description": "02 Site Utilities",
"unitPrice": "2000",
"projectActivity": {
"chartCodes": []
}
}
]
}
Desired output:
{
"order": {
"orderLineItems": {
"orderLineItem": [
{
"lineItemName": "Architecture Fees",
"unitCost": "1000",
"contractDetails": {
"activity": "20_7845_9999"
},
"additionalCoding": {
"workOrderNumber": "2"
}
},
{
"lineItemName": "02 Site Utilities",
"unitCost": "2000",
"contractDetails": {
"activity": "20_null_9999"
},
"additionalCoding": {
"workOrderNumber": "2"
}
}
]
}
}
}
Mapping I tried inside mapper:
mapping expression I used:
$items.map(val=>{"lineItemName":val.description,"unitCost":val.unitPrice,"contractDetails":{"activity":'20_'+jsonPath($,"items[*].projectActivity.chartCodes[*].chartCode").find(x=>x.supplementalType=='BOMA').uniqueCode+'_9999'},"additionalCoding":{"workOrderNumber":JSON.stringify($project.projectId)}})
It gives me output as follows:
{
"order": {
"orderLineItems": {
"orderLineItem": [
{
"lineItemName": "Architecture Fees",
"unitCost": "1000",
"contractDetails": {
"activity": "20_7845_9999"
},
"additionalCoding": {
"workOrderNumber": "2"
}
},
{
"lineItemName": "02 Site Utilities",
"unitCost": "2000",
"contractDetails": {
"activity": "20_7845_9999"
},
"additionalCoding": {
"workOrderNumber": "2"
}
}
]
}
}
}
So here, I tried many a ways to manipulate the BOMA value which should come as distinct, the way it shows up in input, like for item 1 we have value available but for item 2 we should get null (or any other value, as coming from source), but the final working mapping I could figure out is mentioned above and it's basically mapping first BOMA code encountered in all the list object values.
Appreciate any help here!
Please let me know in case additional details needed here.
Thanks,
Deepti
- Aleksandar_A3 years agoContributor III
Hello @Rahul,
You can compare the two list by first merging them using the Join Snap. Then, using the following expression in a Mapper Snap to compare the lists:
$api_list.length == $snowflake_list.length ? ($api_list.filter(x => $snowflake_list.indexOf(x) != -1).length == $api_list.length) : false
Here is a sample pipeline:
–sl-comm-compare-lists_2023_07_08.slp (6.6 KB)Let me know if this is of any help. 🙂
Regards,
Aleksandar.Aleksandar_A - Can you please share the sample pipeline as I am getting Page not found error
- Aleksandar_A2 years agoContributor III