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

How to list all Users of a Team in Dynamics 365

I'm trying to find a way of returning a list of all the Users within a specific Team in Dynamics 365 but can't figure out the correct filter query.  Because there is a N:N relationship between users and teams, I'm a bit lost.

 

Can anybody can give me some advice on using the filter query to filter related N:N entities?

 

Thanks,

Martyn

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: How to list all Users of a Team in Dynamics 365

Hi @Martynbooth 

 

If you know the guid of the Team that you want to get the users for then you can use the following to retrieve all of the Users.

 

chrome_2019-02-28_17-41-50.png

 

As shown above, firstly create a List Records action. You will need to enter a custom entity value of "teammemberships" and a filter of "teamid eq TEAMGUIDHERE". After this add a Parse JSON action. This is necessary as we are using a custom entity type that Flow is not aware of. Use the following schema...

 

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "@@odata.etag": {
                "type": "string"
            },
            "systemuserid": {
                "type": "string"
            },
            "versionnumber": {
                "type": "integer"
            },
            "teammembershipid": {
                "type": "string"
            },
            "teamid": {
                "type": "string"
            }
        },
        "required": [
            "@@odata.etag",
            "systemuserid",
            "versionnumber",
            "teammembershipid",
            "teamid"
        ]
    }
}

Then finally add a Get Record action using the systemuserid value from the Parse JSON action. This will generate the loop. After each Get Record action you will have details on the user within the Team.

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

View solution in original post

9 REPLIES 9
Highlighted
Super User
Super User

Re: How to list all Users of a Team in Dynamics 365

Hi @Martynbooth 

 

If you know the guid of the Team that you want to get the users for then you can use the following to retrieve all of the Users.

 

chrome_2019-02-28_17-41-50.png

 

As shown above, firstly create a List Records action. You will need to enter a custom entity value of "teammemberships" and a filter of "teamid eq TEAMGUIDHERE". After this add a Parse JSON action. This is necessary as we are using a custom entity type that Flow is not aware of. Use the following schema...

 

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "@@odata.etag": {
                "type": "string"
            },
            "systemuserid": {
                "type": "string"
            },
            "versionnumber": {
                "type": "integer"
            },
            "teammembershipid": {
                "type": "string"
            },
            "teamid": {
                "type": "string"
            }
        },
        "required": [
            "@@odata.etag",
            "systemuserid",
            "versionnumber",
            "teammembershipid",
            "teamid"
        ]
    }
}

Then finally add a Get Record action using the systemuserid value from the Parse JSON action. This will generate the loop. After each Get Record action you will have details on the user within the Team.

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

View solution in original post

Highlighted
Frequent Visitor

Re: How to list all Users of a Team in Dynamics 365

@LeeHarris  You absolute hero! That worked like a charm, thanks so much 🙂

Highlighted
New Member

Re: How to list all Users of a Team in Dynamics 365

Dear, 

 

please can you explain more how you performed the below: 

 

......"You will need to enter a custom entity value of "teammemberships" and a filter of "teamid eq TEAMGUIDHERE". "

Highlighted
Super User
Super User

Re: How to list all Users of a Team in Dynamics 365

Hi @elieaboujaoude 

Within the List Records action, when selecting the Entity in the drop down list, scroll right to the bottom and you should see an option for Use Custom Value. Click this and then you can type "teammemberships" in the entity box.

The filter can be typed as shown, replacing the text TEAMGUIDHERE with the id of the Team you want to get the memberships of.

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

Highlighted
New Member

Re: How to list all Users of a Team in Dynamics 365

let me please re-explain my question

 

Steps i followed: 

1- Created a team and added two users inside the standard "Team" object within D365 and i have it's GUID. 

2- Created a Custom Entity called " Teammembers" and it only contains name and owner. 

 

My question, how can i link the custom entity to the teamid? is it just a lookup field that i need to link this custom entity to "Team"

 

A

Highlighted
Super User
Super User

Re: How to list all Users of a Team in Dynamics 365

Hi @elieaboujaoude 

A lookup field to Team would link the two yes. However, the teammemberships entity is an out of the box entity that already exists so you do not need to create a custom entity to achieve this. Flow cannot see this Entity in the list though so you have to enter it as a custom value within the Flow action.

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

Highlighted
New Member

Re: How to list all Users of a Team in Dynamics 365

Ohhh ! I though i read somewhere it is a custom entity. Thanks for the great help. The workflow gave an error at stage: Increment current counter in Dynamics by 1  . how can i write the add function ? 

 

InvalidTemplate. Unable to process template language expressions in action 'Increment_current_counter_in_Dynamics_by_1' inputs at line '1' and column '2649': 'The template language function 'add' expects two numeric parameters: the first summand as the first parameter and the seccond summand as the second parameter. The function was invoked with '1' parameter(s). Please see https://aka.ms/logicexpressions#add for usage details.'.

Highlighted
Super User
Super User

Re: How to list all Users of a Team in Dynamics 365

Hi @elieaboujaoude 

This sounds like you are just missing a parameter from the function. As this is now unrelated to the original question it might be better to open a new discussion and add some screenshots of your issue. This will make it easier for others with a similar problem to find a solution. Feel free to tag me and I will see if I can help resolve it.

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

New Member

Re: How to list all Users of a Team in Dynamics 365

Thanks for your prompt reply. the error is in the last action: 

 

  1. Finally, use the Update a Record action to update the case that was created at the beginning of the flow by changing the owner to be the string returned from the teamUsers array like so:

variables('teamUsers')[variables('nextUserCounter')]

 

Should i only add : variables('teamUsers')[variables('nextUserCounter')] insideOwner field?

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

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