cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

How to use object-id within a collection

Hi All,

 

I'm working on an app that pulls all the AzureAD groups and it's members into Powerapps.
This way I can see all the AzureAD groups and downdrill per group to see it's members.
Using a Graph API I'm able to pull the data of the groups (i.e. Object-id) into my app and store it in a collection within Powerapps.

 

But when I want to use the AzureAD.GetGroupMembers connector, I need to enter the object-id of a specific group.
So I need to hard code all the object-id's into the app, which isn't very flexible.
I would rather use the object-id's that are stored in the collection, so that if AzureAD groups get modified the Powerapps app will update automatically.

 

Does anyone know a way to use the object-id's within the collection with the AzureAD.GetGroupMembers connector?
Or is there a different way to solve this?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hi @TK421 :

The command "https://graph.microsoft.com/v1.0/groups" does not require you to enter any parameters, you only need to use it to get all the Groups in the organization (you seem to have done it).

Then you just need to use ForAll to traverse the list of Groups, and then use the standard connector to get the members in the Group,I've made a test for your reference:

 

ClearCollect(
    ccccc, /*ccccc is my custom collection*/
    ForAll(
        ListAllGroupsInMyOrg.GetGroups().value, /*ListAllGroupsInMyOrg is my custom connection*/
        {
            GroupName: displayName,
            GroupID: id,
            Member: Office365Groups.ListGroupMembers(id).value
        }
    )
)

 

84.gif

Best Regards,

Bof

View solution in original post

6 REPLIES 6
Highlighted
Community Support
Community Support

Hi @TK421 :

Do you want to get a list of Groups and get the corresponding Group Member according to each Group?

The point is using Office365Groups connector.I'v made a test for your reference:

1\Add an Office365Groups connection.

2\Add a button and set it‘s OnSelect property to:

 

ClearCollect(
    YourCustomCollection, /*YourCustomCollection is a custom collection*/
    AddColumns(
        Office365Groups.ListOwnedGroups().value,
        "Members", /*Add a new column named Members to store GroupMember information*/
        Office365Groups.ListGroupMembers(id).value
    )
);

 

79.gif

Best Regards,

Bof

Highlighted

Hi Bof,

 

Thanks for your reply, but with your solution only the groups where my user is a member are present in the collection.

I want all the groups to be in a collection (even the groups I'm not a member of).

And of those groups I want it's members. 

 

A way to do this is:

https://knowhere365.space/powerapps-azure-active-directory-groups/ 

 

But then I need to hardcode all the object-id's of the groups.

And that's not flexible. 

 

Highlighted

Hi @TK421 :

If you want to get all groups (including Distribution list) in your tenant within your app, please take a try with the following workaround:

You need to add a Office 365 Users connection and Azure AD connector within your app firstly. Then set the OnStart property of the App control to following:

ForAll(
       Office365Users.SearchUser({top:100}),
       If(!IsEmpty(AzureAD.GetMemberGroups(Mail,false).Value), Collect(GroupIDs, AzureAD.GetMemberGroups(Mail, false).Value))
);
ClearCollect(
             AllGroups,
             Distinct(GroupIDs, Value))

All Group IDs are stored in a collection named "AllGroups".

Note: I assume that each user in your tenant belongs to one group at least. If there is one user does not belong to any group, above formula would execute fail.In addition, the execution speed of the above formula will be very slow.

 

If above solution could not work on your side, as an alternative solution, you could consider create a custom connector based on Microsoft Graph API within your PowerApps to achieve your needs.

More details about creating a custom connector based on Microsoft Graph API within PowerApps, please check the following blog:

https://gotoguy.blog/2017/12/17/access-microsoft-graph-api-using-custom-connector-in-powerapps-and-f...

More details about "List groups" action of Microsoft Graph API, please check the following article:

https://docs.microsoft.com/en-us/graph/api/group-list?view=graph-rest-1.0&tabs=cs

Note: Based on the needs that you mentioned, I think the custom connector may be the better way for your scenario.

Best Regards,

Bof

 

Highlighted

Hi Bof,

 

Thanks for your help. Using Graph I'm able to get the necessary data with the following query:

 

https://graph.microsoft.com/v1.0/groups?$expand=members

 

This gives me a ton of data and before I refine this, I want to make sure that all the data can be imported into Powerapps.

So I defined an Action in the Custom Connector screen (and also using the info you provided), but when I try to import the data into a collection in Powerapps, I do get the Group data, but not it's members:

 

TK421_0-1599558032472.png

Furthermore, I'm not able to test this specific custom connector properly.

If I don't enter a value, the test is successful, but with any other value the test goes into error:

 

TK421_1-1599558192001.png

Any suggestions?

 

Thanks in advance.

Highlighted

Hi @TK421 :

The command "https://graph.microsoft.com/v1.0/groups" does not require you to enter any parameters, you only need to use it to get all the Groups in the organization (you seem to have done it).

Then you just need to use ForAll to traverse the list of Groups, and then use the standard connector to get the members in the Group,I've made a test for your reference:

 

ClearCollect(
    ccccc, /*ccccc is my custom collection*/
    ForAll(
        ListAllGroupsInMyOrg.GetGroups().value, /*ListAllGroupsInMyOrg is my custom connection*/
        {
            GroupName: displayName,
            GroupID: id,
            Member: Office365Groups.ListGroupMembers(id).value
        }
    )
)

 

84.gif

Best Regards,

Bof

View solution in original post

Highlighted

Hi Bof,

 

Thanks for your help.

This worked like a charm.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,195)