2

I'm using a SQL Connector in Power Automate / Logic Apps / Flow.

How can I see if a value exists in a table without using SPs, aka directly against the table?

I tried using GetRowsV2 action. When the value exists, I get the nice body() block below.
What kind of dynamic expression can I use to see if approver_email is in that body? I'm missing something fundamental with the expressions here.

Thanks.

GetRows -> Body

{
"@odata.context": "https://canada-001.azure-apim.net/apim/sql/shared-sql-2618c6c8/$metadata#datasets('default%2Cdefault')/tables('%5Bdbo%5D.%5BDELEGATION_OF_AUTHORITY%5D')/items",
"value": [
{
   "@odata.etag": "",
   "ItemInternalId": "1706f376-b713-47f7-9bf2-a046bd899fe4",
   "APPROVER_EMAIL": "jhealy@contoso.com"
}]}

I wound up using the below formula and seeing if its >0. Surely a better way out there?

length(body('Get_Rows_V2')?['value'])

Thanks...

Joe Healy
  • 5,769
  • 3
  • 38
  • 56

1 Answers1

1

Per my understanding, you just want to judge if the body contains "APPROVER_EMAIL". So why not use contains method in logic app ? You can convert the "value" to string first, and then use "contains" method to judge if the string "value" contains "APPROVER_EMAIL".

contains(string(body('Get_Rows_V2')?['value']), 'APPROVER_EMAIL')
Hury Shen
  • 14,948
  • 1
  • 9
  • 18
  • contains fails out if there is no 'value' array returned. Trying to avoid onerr. length is what I worked up, as above. thanks for proposal though, it works if the value is always returned. – Joe Healy Dec 01 '19 at 17:57