cancel
Showing results for 
Search instead for 
Did you mean: 

Build Switch Case to support Dynamic Expressions in Array Queries

Currently, if I want to search a field for an array of possible values, I have to use Switch Case and manually construct each of the items I want to search for. Instead, I'd like to be able to use Switch Case, and say "search for *any* of these values, and if found, perform an action that says "found X". That's quite cumbersome today.

Status: New
Comments
Level: Power Up

I'm currently struggling with the same thing with parsing, the list of items I need to check that equal to is from an array of values that gets larger over time, so I end up with a large list of OR expressions that I don't want to maintain going forward.  Please see below.

 

What's more difficult is this flow's array is different depending on our clients, because this for sending communications to different groups and that array source is different for each group.  We're using groups to set some preliminary communications management for clients.

 

Is there any workaround besides manually maintaining and adding these array values to this dynamic expresssion?

 

Example:

@or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(
equals(string(item()), '4102'),
equals(string(item()), '4118')),
equals(string(item()), '1648')),
equals(string(item()), '1686')),
equals(string(item()), '1699')),
equals(string(item()), '3506')),
equals(string(item()), '3543')),
equals(string(item()), '8669')),
equals(string(item()), '8769')),
equals(string(item()), '8821')),
equals(string(item()), '8921')),
equals(string(item()), '8554')),
equals(string(item()), '8754')),
equals(string(item()), '8784')),
equals(string(item()), '8824')),
equals(string(item()), '8924')),
equals(string(item()), '4100')),
equals(string(item()), '5618')),
equals(string(item()), '3074')),
equals(string(item()), '6631')),
equals(string(item()), '8848')),
equals(string(item()), '8948')),
equals(string(item()), '2619')),
equals(string(item()), '2620')),
equals(string(item()), '2621')),
equals(string(item()), '2622')),
equals(string(item()), '2623')),
equals(string(item()), '2624')),
equals(string(item()), '2625')),
equals(string(item()), '2626')),
equals(string(item()), '8870')),
equals(string(item()), '3536')),
equals(string(item()), '3548'))

 

Thank you,

Matt

Level: Power Up

Version:1.0 StartHTML:000000280 EndHTML:000005999 StartFragment:000002043 EndFragment:000005967 StartSelection:000002043 EndSelection:000005967 SourceURL:https://powerusers.microsoft.com/t5/Flow-Ideas/Build-Switch-Case-to-support-Dynamic-Expressions-in-A...

I ended up solving this by creating an array with the values and performing lookups past the array length, in the OR statements, since values past the length of the array are NULL, that means that NULL values will never be matched to the item() in the loop when it runs through the OR conditional.

 

I went past the length of the array by always specifying the last index of 51, since I analyzed that I'll never have a list larger than 51 values to lookup against.

 

The code snippet that you can re-use is below, I realize the solution is a bit of a workaround but it can be scaled and pasted for any number of large amounts of data to compare against, and it won't fail/error when it gets past the end of the array - WHICH IS A GOOD THING:

 

@or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(
equals(string(item()), outputs('Compose_3')?[0]),
equals(string(item()), outputs('Compose_3')?[1])),
equals(string(item()), outputs('Compose_3')?[2])),
equals(string(item()), outputs('Compose_3')?[3])),
equals(string(item()), outputs('Compose_3')?[4])),
equals(string(item()), outputs('Compose_3')?[5])),
equals(string(item()), outputs('Compose_3')?[6])),
equals(string(item()), outputs('Compose_3')?[7])),
equals(string(item()), outputs('Compose_3')?[8])),
equals(string(item()), outputs('Compose_3')?[9])),
equals(string(item()), outputs('Compose_3')?[10])),
equals(string(item()), outputs('Compose_3')?[11])),
equals(string(item()), outputs('Compose_3')?[12])),
equals(string(item()), outputs('Compose_3')?[13])),
equals(string(item()), outputs('Compose_3')?[14])),
equals(string(item()), outputs('Compose_3')?[15])),
equals(string(item()), outputs('Compose_3')?[16])),
equals(string(item()), outputs('Compose_3')?[17])),
equals(string(item()), outputs('Compose_3')?[18])),
equals(string(item()), outputs('Compose_3')?[19])),
equals(string(item()), outputs('Compose_3')?[20])),
equals(string(item()), outputs('Compose_3')?[21])),
equals(string(item()), outputs('Compose_3')?[22])),
equals(string(item()), outputs('Compose_3')?[23])),
equals(string(item()), outputs('Compose_3')?[24])),
equals(string(item()), outputs('Compose_3')?[25])),
equals(string(item()), outputs('Compose_3')?[26])),
equals(string(item()), outputs('Compose_3')?[27])),
equals(string(item()), outputs('Compose_3')?[28])),
equals(string(item()), outputs('Compose_3')?[29])),
equals(string(item()), outputs('Compose_3')?[30])),
equals(string(item()), outputs('Compose_3')?[31])),
equals(string(item()), outputs('Compose_3')?[32])),
equals(string(item()), outputs('Compose_3')?[33])),
equals(string(item()), outputs('Compose_3')?[34])),
equals(string(item()), outputs('Compose_3')?[35])),
equals(string(item()), outputs('Compose_3')?[36])),
equals(string(item()), outputs('Compose_3')?[37])),
equals(string(item()), outputs('Compose_3')?[38])),
equals(string(item()), outputs('Compose_3')?[39])),
equals(string(item()), outputs('Compose_3')?[40])),
equals(string(item()), outputs('Compose_3')?[41])),
equals(string(item()), outputs('Compose_3')?[42])),
equals(string(item()), outputs('Compose_3')?[43])),
equals(string(item()), outputs('Compose_3')?[44])),
equals(string(item()), outputs('Compose_3')?[45])),
equals(string(item()), outputs('Compose_3')?[46])),
equals(string(item()), outputs('Compose_3')?[47])),
equals(string(item()), outputs('Compose_3')?[48])),
equals(string(item()), outputs('Compose_3')?[49])),
equals(string(item()), outputs('Compose_3')?[50])),
equals(string(item()), outputs('Compose_3')?[51]))

 

Thank you much!

Matt