Get Count of records retrieved in CDS connector in a Flow | Power Automate

In several applications, you need to know how many record were retrieved in the List records Action in a Common Data Service connector in order to take a decision.

Scenario

Typically, let’s say I know only 1 record should exist in order to take that record forward and do an action. But how do I know when only 1 record was received? That’s when you use Control

Check Count

Now, let’s say you want to want to retrieve Accounts and know how many were returned (Perhaps, you want to proceed only if at least 1 or more were retrieved)

  1. This is my List Records action and I’ve named it as Get All Records.
    defaultListRecords
  2. And just to display how many records are retrieved, I’ll use a variable. Usually, you would use this in condition (which we’ll get to in a bit)
    initVar
  3. So, in the expressions to set the Variable, under Dynamic Content, I’ll write –
    writeHereand write the below expressioncountactualExpression
    which is set to the variable
    setVar
  4. And here are the results. I have 101 Accounts
    count

Using it for comparison

This is one of the typical use cases where you want to proceed only if you have at least 1 record –
typicalUseCase

Here are some more Flow related topics you might want to take a look at –

  1. Number Formatting in a Flow | Power Automate
  2. Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
  3. Switch-Case in a Flow | Power Automate
  4. Setting Retry Policy for an HTTP request in a Flow | Power Automate
  5. Retrieve only active Dynamics 365 CE licensed Users in CDS connector in Power Automate
  6. Button Flow in Power Automate to replicate a Quick Create Form in D365 CE
  7. Make HTTP request from Flow in Power Automate
  8. Create a To-Do List Item of Important Outlook Emails using Power Automate

Hope this quick tip helps!

Call a Dynamics 365 Action from Flow [Bound and Unbound Actions] | Power Automate

Ever wondered how to call an Action from a Flow using the new Common Data Service (Current Environment) connector? There are 2 actions to perform this –

Here’s a quick post to demonstrate that and the difference between Perform a bound action and Perform an unbound action in the CDS (Current Environment) connector.

Note that the connector used here is Common Data Service (Current Environment) connector which is available only if you are creating a Flow inside a Solution, not outside.
currentEnv
Check more on this connector here – Selecting (Current) in Environment in Power Automate CDS connector and why it matters

 

Unbound Action

Bound Action meaning calling an Action in Dynamics 365 that is bound to any one entity i.e. which is not a Global Action
BoundAction

  1. In this example. I’m creating a Flow that will call a Bound Action which runs on Account entity.
    insideBoundAction_Body
  2. And the InputName field shown above will simply take a string field and reflect the same as it is in Output
  3. Now, I am using Perform a bound action Action from the Common Data Service (Current Environment) connector as shown below-
    selectBount
  4. Once you select Perform a bound action, you’ll need to select what entity the Action is tied to with the following properties –
    Entity Name: Name of the entity the Action is bound to
    Action Name: Name of the action (not Display Name)
    Item ID: Guid of the record of that entity. Typically this is dynamically retrieved from other operations above this step (I’ve simply hard-coded one)
    Parameters: In my example, I’m passing a parameter called ‘InputName’ and I’m passing a string called “Account Name”
    boundBody
  5. Operation-Now, once my Bound Action is executed, I can see the below results which it will return i.e. OutputName field after composing with InputName inside the Action
    boundOutput
  6. Further, you can use the following Output from the Bound Action i.e. the Response or the Output parameters the Action is sending.
    showBoundResponse

Unbound Action

Unbound Action meaning calling an Action that is not bound to any entity in Dynamics 365 and is set to None (Global)
CreateUnboundAction

 

  1. In my Unbound Action, I am simply passing InputName through to the OutputName field as is.
    insideUnboundAction_Body
  2. Now, I’ll use Perform an unbound action from the Actions in Common Data Service (Current Environment) connector
    selectUnbound
  3. Once you select this action, you simply need to select the name of the Action from Dynamics 365 itself (Again, not Display Name) and pass along any Input parameters for the same, if any.
    unboundBody
  4. Operation – Now, once you execute this, the Action will execute and give you a response as below
    unboundOutput
  5. Further, you can select what you want to use from the response of the action step i.e. either the Response itself or the Output Parameters, if any.
    showUnboundResponse

 

Here are some other Power Automate / Flow posts that might interest you –

  1. Switch-Case in a Flow | Power Automate
  2. Enable Flow button on D365 Ribbon
  3. Secure Input/Output in Power Automate Run History
  4. Setting Retry Policy for an HTTP request in a Flow | Power Automate
  5. Using Parse JSON to read individual List Records in Flow|Power Automate
  6. Make HTTP request from Flow in Power Automate
  7. Retrieve only active Dynamics 365 CE licensed Users in CDS connector in Power Automate
  8. Create a To-Do List Item of Important Outlook Emails using Power Automate
  9. RSS notifications to your phone using Power Automate
  10. Selecting (Current) in Environment in Power Automate CDS connector and why it matters
  11. Button Flow in Power Automate to replicate a Quick Create Form in D365 CE
  12. Approval Process using Power Automate

Hope this simple example helps explain the actions!