Let’s take a simple use case where you need to have a Microsoft Team created in Teams and have the Project Members added to the Microsoft Teams’ Project Team.
You can simply do this using 2 simple Flows in Power Automate
Scenario & Setup
If you are a PSA Customer, you would want to create a Team in Microsoft Teams based on what Project it is and then add Team Members of the Project as Team Members in the Microsoft Teams’ Team you created.
Let’s look at a Simple example of how you can do this. And further, you can enhance the implementation yourselves based on whether a Project becomes Inactive, or someone is to be removed from the Project Team.
I’ll be creating 2 Flows for this purpose –
- One that will create a Team in Microsoft Teams upon Project Creation and
- Other, will add Member to the Project’s MS Team upon addition of the Team Member in Project in PSA/Project Operations.
Create a Team for the Project
Let’s look at the first scenario where you can create a Team in Microsoft Teams once create a Project in PSA.
- Flow to trigger off of a creation of a Project.
- Now, search for create a team in the next step to find a Microsoft Teams connector’s Action to create a Team in Microsoft Teams.
- Assign the Name of the Project and Description of the Project for easy understanding. You can make the team Private which is ideal to keep users’ Teams cleaner and also keeps Project discussions isolated if that’s the need.
- Once a Team is created, I’ve created a field on Project record to hold the MS Teams’ ID for other references.
Add a step to update the Project back with the created MS Teams’ ID like this
And in that, I’ll update the Created Team’s ID
- Now, fetch the Project Manager’s User record in CDS (PSA, basically) so that the User’s ID can be used to make the Owner of the Team you are creating.
- Next, you need to add Members to the Team. Look for add a member to the team and you’ll find Microsoft Teams’ action which you can use.
- Here’s how the Add a team member looks like.
- Now, this is a little tricky. Since you don’t get the Dynamic Values right away in this Action, click on Add a custom item.
- In Add a custom item, you can add the Team ID of the MS Team you just created for the Project in step #3 above.
Once you add it, it’ll look like below
- And for the User’s AAD ID step, set the System User’s (fetched in #5)
Add Azure AD Object ID
- Now, the last step looks set.
Add Members to the Project Team
Let’s work on the other scenario with other Flow. This will be on trigger of a creation of a project Team Member.
- This second will fire off on creation of a Project Team Member. Hence, the trigger on Create of a Project Team Member.
- I’ll get the Project record since I need the MS Teams ID which is a custom field we created to store the MS Team’s ID on the Project.
Again, you can do this easily if you know how to get related records. I’ve done an extra step for simplicity.
- Now, the next step is to retrieve the Bookable Resource‘s Record. In turn, we’ll retrieve the System User record associated with the Bookable Resource record on the Project Team so that the System User’s ID can be used.
Just because I need the Azure AD Object ID (User) entity, I’ve written a fetch XML on the Bookable Resource entity to go and get the User record’s Azure AD Object ID. I’ll need this to map it in the step where we’ll add the Member to the Project’s created Team.
My step to retrieve Bookable Resource + System User’s Azure AD ID looks as below. Make sure you select the Bookable Resource GUID reference from the trigger i.e. the Creation of the Project Team Member record to ensure we only get 1 record.
- Then, I’ll simply generate a Parsed JSON after the above Step so that I can get to select the required attribute to select in the Team’s Add a Team Member step (Because the related field is not available for Dynamic Values) (In case you know how to directly write using outputs() function, that should be good enough too!!)
- Now, add the Team Member to the Project’s Team in MS team. Again, as mentioned above in the previous Flow, use the Add a member to a team Action from Microsoft Teams connector to do so.
Now, add the Team’s ID in the Team field.
On the Team field, you’ll need to Add a custom Value like we did in the previous Flow.
- And for the final step, in the User AAD ID for the user to add to a team step, you can pick the parsed Azure ID field from #4 above.
- As soon as you select from Parse, the Flow step will be converted to Apply to each. But that’s because we used List records which returns multiple values. Even though Apply to each is applied, this will logically run only once anyway!!
- Now in the user AAD
Now’s let’s see all this in action.
- Let’s create a Project in PSA. Notice I’ll enter the name and the Description since we are creating a Team in MS Teams and that’s what we are filling out. Notice that MS Teams Project ID is blank. Our Flow will populate that once a Team is created in Microsoft Teams.
Notice that Joe Danny is the Project Manager on the Project, he will be the Owner of the Team we are creating in MS Teams as per our first Flow.
- A Team like this will be created in Microsoft Teams.
- Also, notice that in the Project in PSA, a MS Teams Project ID will be populated too.
- Also, notice that Joe Danny is the Owner of the Team since Joe is the PM on the Project.
- Now, let’s add 1 more Team Members to the Project in PSA. Now, I’ve added a new Team Member Priyesh in the Project’s Team.
- That team member also get added as Members in Microsoft Teams in the Project’s Team. This is from out second Flow we created to add the Team Members to the created Teams for a PSA Project.
Here are some more enrichments you’ll need to do to handle some scenarios –
- Separately handle if a Project is Canceled/Deactivated for some reason.
- Remove Members from an MS Teams if they are removed from the Project.
Hope this was useful.
Here are some more posts about Project Service Automation (PSA) in Dynamics 365 / Microsoft Teams that might be helpful –
- Cancelled Bookings Imported in Time Entries in Dynamics 365 PSA issue | [Quick Tip]
- Task Completion reminder using Flow Bot in Microsoft Teams | Power Automate
- Change Booking Status colors on Schedule Board for Field Service/PSA [Quick Tip]
- Additional columns in PSA v3 Schedule view
- Check Managed Solution failures in Solution History in Dynamics 365 CRM
- Modify Project tab’s view in Schedule Board in PSA v3 | Quick Tip
- Update Price feature in D365 PSA v3
- A manager is required for non-project time entries, absence, and vacation error in D365 PSA v3
- Time/Expense Entry Rejection comments in D365 PSA v3
- PSA v3 View Custom Controls used on Project form