@Lee Yong Sheng There are a few ways you could do this and also simplify your flow a bit
- Use the Inline Code Action
This allows you to use JavaScript to process the JSON all in a single step and you could output any array that you just use to send emails from. This simplifies the flow very much and allows for simpler processing of the data using JavaScript methods like map/reduce/etc. - Use an Azure Function
This is another code option that you could use if JavaScript isn't your thing, and you would prefer using another language like C# or Python. This option has the downside of having another component unlike the inline code action which is contained within the Logic App. - Initialize an object that stores the information for each vessel
This is like the inline code action except that you would do the same steps using Logic App built-in actions and functions for collections and objects. The flow would be something like this- Build an array of vessel identifiers; either from a query or you could add the ones seen in the list of documents while checking for duplicates
- Build an object with the aggregated data
- Build an object that has vessel identifiers as keys and the corresponding aggregated data as values
- Loop over the vessels, getting the data and sending an email for each