Hi:
I have the following format in the flow (below) and needed to convert to another format (below - Output). Is this possible?
Format in Flow:
[
{
"FileName": "abc.pdf",
"rpa": "true"
},
{
"FileName": "abc.pdf",
"robotic process automation": "true"
},
{
"FileName": "abc.pdf",
"process automation": "true"
},
{
"FileName": "pqr.pdf",
"rpa": "true"
},
{
"FileName": "pqr.pdf",
"robotic process automation": "false"
},
{
"FileName": "pqr.pdf",
"process automation": "true"
}
]
But need to convert to this format (output):
[
{
"FileName": "abc.pdf",
"rpa": "true",
"robotic process automation": "true",
"process automation": "true"
},
{
"FileName": "pqr.pdf",
"rpa": "true",
"robotic process automation": "false",
"process automation": "true"
}
]
Thanks. This works
@Tak103 ,
You could try converting the following Powershell code into workflow logic.
$json = @"
[
{
"FileName": "abc.pdf",
"rpa": "true"
},
{
"FileName": "abc.pdf",
"robotic process automation": "true"
},
{
"FileName": "abc.pdf",
"process automation": "true"
},
{
"FileName": "pqr.pdf",
"rpa": "true"
},
{
"FileName": "pqr.pdf",
"robotic process automation": "false"
},
{
"FileName": "pqr.pdf",
"process automation": "true"
}
]
"@
$data = ConvertFrom-Json $json
$result = @{}
$data | ForEach-Object {
$fileName = $_.FileName
if (-not $result.ContainsKey($fileName)) {
$result[$fileName] = @{
"FileName" = $fileName
}
}
foreach ($key in $_.PSObject.Properties | Where-Object { $_.Name -ne "FileName" }) {
$result[$fileName][$key.Name] = $key.Value
}
}
$finalResult = $result.Values
$finalResult | ConvertTo-Json
Hi @Tak103 I'm not sure this is the best way to approach for this can you not change the way the information is passed to the Power Automate?
Have this in the correct format rather than having multiple lines for each pdf can you not collect this together and then pass it as the desired output? Doing this dynamically would prove difficult?
Try passing information as this in the 1st instance:
[
{
"FileName": "abc.pdf",
"rpa": "true",
"robotic process automation": "true",
"process automation": "true"
},
{
"FileName": "pqr.pdf",
"rpa": "true",
"robotic process automation": "false",
"process automation": "true"
}
]
I did try using Select data operation but this wouldn't give me the desired out put this would just create multiple PDF items and append the additional columns as null values:
Sorry I couldn't help any further
Andrew
Michael E. Gernaey
497
Super User 2025 Season 2
David_MA
436
Super User 2025 Season 2
Riyaz_riz11
244
Super User 2025 Season 2