Reputation: 25
edit - added two pictures first is a failed step and the second is a successful step
I have a power automate script that utilized the AD Check_group_membership_(V2) to evaluate group membership I then want to run a conditional check on that membership and if true - one email thread, if false (null) then a separate response.
I BELIEVE I am having issues properly formatting the empty() function to evaluate the existence of a group membership. The positive evaluation is running fine, the negative however just stops with no ability to see into the code beneath the conditional (picture below).
this is my configuration of the check membership that so far works correctly.
My approach was to use the empty function, pass in the groupid: from the check GM above: if 1 then true, of null then false. I am not sure in this case what to put for the collection, what to put for array value and probably formatting the string in general (or i may be barking up the wrong tree - highly probable).
I tried following some of the help from links like this: https://manueltgomes.com/microsoft/power-automate-empty-function/ but was too general for my limited experience to follow. Any education here would be greatly appreciated.
I have tried numerous string values and formats, but I am, not exactly sure what I am changing (I am not sure what the functional components are that I am passing...so not sure what I am changing and why...swinging blindly).
In the end, my hope is that if the AD group check returns 0, I can set a condition to send an email back to the user and give them the option to submit a ticket to be added to the group they were just evaluated for.
Upvotes: 0
Views: 7802
Reputation: 11262
I'm a little confused as to whether or not you care about the contents of the returned array. From what I can work out, you essentially want to check if the response contains an empty array or not and from that, you'll take the relevant path to do what you need to do.
This flow demonstrates a basic condition to determine if an array is empty or not.
I initialised two arrays, one empty and one not. They essentially represent the array returned by your call to Check group membership (V2)
.
I then have two conditional conditions, the first checks the Array With Values
variable and the second the Empty Array
variable.
These are the those two steps ...
Left Hand Side Condition = length(variables('Array With Values'))
Left Hand Side Condition = length(variables('Empty Array'))
... and as you can see by the first screen shot, checking the length()
of an array is a way to determine if it is empty or not.
Of course, you can also use empty()
, as you've tried, you just need to make sure the expression sits on the left hand side of the condition ...
Left Hand Side Expression = empty(variables('Empty Array'))
There are a few ways to approach it to get the output you're after.
Upvotes: 2