In this post, we will walk through how to build a flow in Power Automate to extend CRM information into Teams. Our use case will be simple: When a new Lead is assigned to me, Teams should alert me via chat.
We will be using two connectors to build this flow:
Configure the Trigger
1. Select an automated cloud flow.
2. Name your close and choose the trigger: When a row is added, modified, or deleted.
3. Click Create at the bottom.
4. Click in the trigger box to set the following parameters:
- Change Type: Select Added or Modified.
- Table Name: Select Leads.
- Scope: Select Organization.
- Under the “Advanced parameters” section, click the Show all button.

5. Under Filter Rows, enter the value: statecode eq 0. Under Select Columns, enter the value: ownerid.
This Odata expression “statecode eq 0” is looking for any Lead with a status of Open. The column selected “Ownerid” is looking for changes to the Lead Owner field. This can be generated from using the XrmToolBox and the tool FetchXML Builder. This tool will get FetchXML we can use to build a more powerful query.

This completes configuration of the trigger! Now it’s on to the actions.
Configure the Actions
First Action: Get Lead Details
1. Click the + icon under the trigger, then select Add an action.
2. Search from the list of actions to find Dataverse’s action Get a row by ID.
We want to use this first action to get the Lead details that triggered this flow. This way, we can use attributes from that record in the Teams action step.
3. Now, we will configure this action row. Set the following values:
- Table name: Leads
- Row ID: Click in the box, then click the
icon to get values from previous steps. Select Lead to get the unique identifier. Note: you can search “unique identifier” in the search bar to ensure you are getting a GUID.

Tip! You can rename your triggers and actions! Simply click into the heading of the tab that opens (in this example, click Get a row by ID and type the new name in!)
Second Action: Get Lead Owner Details
For the next action, we need to get the details of the Owner so we know who to message on Teams.
1. First, add a new action with the same Dataverse action: Get row by ID.
2. Now, we will configure this action row. Set the following values:
- Table name: Users
- Row ID: Click in the box, then click the
icon to get values from previous steps. Select Owner (Value) from the “Get Lead Details” step. This will return the Lead Owner value.

Third Action: Post a message in Teams chat
On to the third and final action: posting the message in Teams!
1. Add a new action under Teams – look for the action Post message in a chat or channel.
2. Select the following action configuration items:
- Post as: Flow bot
- Post in: Chat with Flow bot
3. Recipient: Click in the box, then click the icon to get values from previous steps. Select Primary email from the get Lead Owner Details step:
4. In the Message, enter details about the Lead using values from prior steps.
Tip! You can get URL to the Lead record by following these steps: Check out the video walkthrough here.
Test Your Flow
That is the flow! Finally, make sure to run the Flow checker, then test your flow to ensure it works as expected.


The post How CRM Admins Can Utilize Power Automate appeared first on Dynamics Communities.