[
{
"Customer ID": "388023432",
"Post Code": "RG132DN",
"Account Name": "Tupert",
"First Name": "Tupert",
"Surname": "Tupertine",
"Provider": "Currys",
"Product Type": "Playstation",
"Plan Type": "Pay Full",
"Pol Number": "WP2323dad"
},
{
"Customer ID": "388023432",
"Post Code": "RG132DN",
"Account Name": "Tupert",
"First Name": "Tupert",
"Surname": "Tupertine",
"Provider": "Currys",
"Product Type": "Xbox",
"Plan Type": "Pay Monthly",
"Pol Number": "Wwdw222323"
},
{
"Customer ID": "238805741",
"Post Code": "RG991HP",
"Account Name": "Carlos",
"First Name": "Adrian",
"Surname": "Grace",
"Provider": "Amazon",
"Product Type": "Playstation",
"Plan Type": "Pay Monthly",
"Pol Number": "3e23e332e"
},
{
"Customer ID": "638805610",
"Post Code": "SP202NP",
"Account Name": "Joseph",
"First Name": "Martin",
"Surname": "Joseph",
"Provider": "Argos",
"Product Type": "Xbox",
"Plan Type": "Pay Monthly",
"Pol Number": "qasw2222qw"
},
{
"Customer ID": "638805610",
"Post Code": "SP202NP",
"Account Name": "Joseph",
"First Name": "Martin",
"Surname": "Joseph",
"Provider": "Amazon",
"Product Type": "Playstation",
"Plan Type": "Pay Full",
"Pol Number": "wd3q45523"
},
{
"Customer ID": "338805910",
"Post Code": "LN121SS",
"Account Name": "Anthony",
"First Name": "Claudius",
"Surname": "Anthony",
"Provider": "Currys",
"Product Type": "Nintendo Switch",
"Plan Type": "Pay Monthly",
"Pol Number": "656yhdf"
},
{
"Customer ID": "338805910",
"Post Code": "LN121SS",
"Account Name": "Anthony",
"First Name": "Claudius",
"Surname": "Anthony",
"Provider": "Currys",
"Product Type": "Xbox",
"Plan Type": "Pay Full",
"Pol Number": "5t4f4f"
}
]
Select (restructure data)
From:
union(
xpath(
xml(json(concat('{"Root":{"Item":', outputs('Compose'), '}}'))),
'//Customer_x0020_ID/text()'
),
json('[]')
)
Surname:
first(
xpath(
xml(json(concat('{"Root":{"Item":', outputs('Compose'), '}}'))),
concat('//Item[Customer_x0020_ID="', item(), '"]/Surname/text()')
)
)
ProiderProductPlan:
chunk(
xpath(
xml(json(concat('{"Root":{"Item":', outputs('Compose'), '}}'))),
concat('//Item[Customer_x0020_ID="', item(), '"]/Provider/text() | //Item[Customer_x0020_ID="', item(), '"]/Product_x0020_Type/text() | //Item[Customer_x0020_ID="', item(), '"]/Plan_x0020_Type/text()')
),
3
)
Post Code:
first(
xpath(
xml(json(concat('{"Root":{"Item":', outputs('Compose'), '}}'))),
concat('//Item[Customer_x0020_ID="', item(), '"]/Post_x0020_Code/text()')
)
)
Apply to each (customer)
Select 2 (text for each product)
From:
items('Apply_to_each')['ProviderProductPlan']
Map:
concat('from ',item()[0],' a ',item()[1],' in a ',item()[2],' plan type')
Compose 2 (text for each customer)
items('Apply_to_each')['Surname']
join(body('Select_2'), ', ')
items('Apply_to_each')['Post Code']
Compose 3 (text array)
Result
[
"Dear Mr Tupertine,\nYou prchased from Currys a Playstation in a Pay Full plan type, from Currys a Xbox in a Pay Monthly plan type.\nYou will receive at your postcode RG132DN a reminder of your purchases and information about how to care for your products.",
"Dear Mr Grace,\nYou prchased from Amazon a Playstation in a Pay Monthly plan type.\nYou will receive at your postcode RG991HP a reminder of your purchases and information about how to care for your products.",
"Dear Mr Joseph,\nYou prchased from Argos a Xbox in a Pay Monthly plan type, from Amazon a Playstation in a Pay Full plan type.\nYou will receive at your postcode SP202NP a reminder of your purchases and information about how to care for your products.",
"Dear Mr Anthony,\nYou prchased from Currys a Nintendo Switch in a Pay Monthly plan type, from Currys a Xbox in a Pay Full plan type.\nYou will receive at your postcode LN121SS a reminder of your purchases and information about how to care for your products."
]