cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cooper01
Continued Contributor
Continued Contributor

Union not working as expected

I have two separate Get group members (Azure AD) actions. Both actions take a different GUID for a security group and return a JSON response of users in the group.

 

What I am trying to do is get a distinct list of users who are in either group (they may be in both). So if Group A has Adam, Ben, and Cathy and Group B has Cathy and Diane, my goal is to get a list with 4 total members: Adam, Ben, Cathy, and Diane.

 

The action to get the members of the first group is renamed to Get Group 1 while the second is Get Group 2.

In a compose action, I am using union to attempt to generate the list of users who are in either list:

union(outputs('Get_Group_1')?['body'], outputs('Get_Group_2')?['body'])

The outputs of union compose are missing some users, although I'm not seeing a clear pattern on who is missing. It has some users who are in both groups and some users who are only in one.

 

Am I misunderstanding how union works or using it incorrectly? Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

It might be because you are using 'body'.  Many connectors return a body object that has an array of values.  Union() works on arrays.  So if you pass it a body it won't necessarily pick up the array inside the body.  Check to see if the dynamic data has both body and value.  If it does then use value instead of body and see if that doesn't work better.

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

3 REPLIES 3
Pstork1
Dual Super User III
Dual Super User III

It might be because you are using 'body'.  Many connectors return a body object that has an array of values.  Union() works on arrays.  So if you pass it a body it won't necessarily pick up the array inside the body.  Check to see if the dynamic data has both body and value.  If it does then use value instead of body and see if that doesn't work better.

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Cooper01
Continued Contributor
Continued Contributor

Thanks for the help @Pstork1 . I actually read the Dynamic content options for the Get members action this time and found that Group Members returns an array. Using this, I changed my union params to 

 

union(outputs('Get_Group_1')?['body/value'], outputs('Get_Group_2')?['body/value'])

 

and it's now working.

Pstork1
Dual Super User III
Dual Super User III

['body/value'] is the JSON for the Value array I was talking about.  



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,469)