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
Solved! Go to Solution.
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.
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.
Follow me on Twitter at @QG_LeeJHarris
Or on LinkedIn at in/leejharris
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.
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.
Follow me on Twitter at @QG_LeeJHarris
Or on LinkedIn at in/leejharris
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". "
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.
Follow me on Twitter at @QG_LeeJHarris
Or on LinkedIn at in/leejharris
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
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.
Follow me on Twitter at @QG_LeeJHarris
Or on LinkedIn at in/leejharris
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.'.
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.
Follow me on Twitter at @QG_LeeJHarris
Or on LinkedIn at in/leejharris
Thanks for your prompt reply. the error is in the last action:
variables('teamUsers')[variables('nextUserCounter')]
Should i only add : variables('teamUsers')[variables('nextUserCounter')] insideOwner field?
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
User | Count |
---|---|
75 | |
20 | |
17 | |
14 | |
13 |
User | Count |
---|---|
127 | |
35 | |
31 | |
28 | |
25 |