question

neptr7 avatar image
0 Votes"
neptr7 Suspended asked MayankBargali-MSFT answered

Using the "items" function with an IF statement

I'm using a Logic App that contains a FOR EACH called "For_each_Item_in_Items". The FOR EACH is running on an array from an SQL query. I'm interested in a column called "Exists" which contains a string of either "ABC" or "DEF".

To get this value I'm using a "Set variable" action as follows:

 @{items('For_each_Item_in_Items')?['Exists']}

This works.

Now I need to take this expression in the "Set variable" action and use it in an IF statement. However I need help with the syntax.

I've tried the following with no success:

 @{if(equals(items('For_each_Item_in_Items')?['Exists'], 'ABC'), '1', '2')}
 @{if(equals({items('For_each_Item_in_Items')?['Exists']}, 'ABC'), '1', '2')}
 @{if(equals(string(items('For_each_Item_in_Items')?['Exists']), 'ABC'), '1', '2')}

Any help or advice would be appreciated.

azure-logic-apps
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

neptr7 avatar image
1 Vote"
neptr7 Suspended answered MayankBargali-MSFT converted comment to answer

This works:

 @if(equals(string(items('For_each_Item_in_Items')?['Exists']), 'ABC'), '1', '2')
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MayankBargali-MSFT avatar image
0 Votes"
MayankBargali-MSFT answered

anonymous user Thanks for posting the resolution. Posting for other community members, you can always refer to the workflow definition function reference document. The usage and example for logical comparison function if are covered here.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.