Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to filter an array in Logic apps based on another array?

In a Logic App I am developing I would like to have the objects in array A from which no entity in array B exists. The arrays have the following structure:

Array A

[{"ExternalId": 1}, {"ExternalId": 2}]

Array B

[{"Id": 2}]

Besides the id's these arrays contain a lot more properties which I will leave away for simplicity.

The result I want is to have the array A filterd based on ExternalId's which are not available in Array B so this should result in the following filtered array:

[{"ExternalId": 1}]

I tried to use the FilterArray action for this but I don't know how to model this. According to the Workflow Definition Language there is a @contains function but I am not able to contruct it in the correct way.

Is it possible to do this in this way? Is there another way to achieve this result in Azure Logic Apps?

like image 592
Wessel Kranenborg Avatar asked Sep 01 '25 06:09

Wessel Kranenborg


1 Answers

Yeah I don't think this would be possible just yet - the only way you could get it would be as follows, but may be easier to just run inside an Azure Function for now.

  1. Compose a new array of just "ExternalId" values (this is so you can use it with @contains() inside filter)
    1. Create a foreach loop with each item in Array B
    2. Inside the foreach loop add a compose with { "body": "@item()['ExternalId']" }

Outside the foreach loop you could do @body('Compose') now and you'd have an array of ExternalId Values ( [ 1 ] in this case above ).

Now create the filter array on Array A, and the filter condition is where @contains(body('Compose'), item())

In the future we plan to support @select() @where() @orderby() type constructs that would make this easier, as well as a map-array action - but still in design. For now you could choose approach above or call an Azure function to do with javascript/C#

like image 114
jeffhollan Avatar answered Sep 02 '25 22:09

jeffhollan