Power Automate – Get Common Data Service (CDS) Record Count

Hi Everyone,

Welcome to the Power Guide Mentorship Program. Today I am going to share PowerGuideTip19, where I will teach you, how can you calculate the count of CDS records.

There are many business requirements, where you have to perform the logic based on CDS/Dynamics 365 record count.

For Example- Retrieve Contact where the email address is arpit@dynamics.community. If count is 0, return no contact found, if the count is 1, return contact exists, if the count is greater than 1 then return duplicate email found. Now, based on the return value you may have to perform various logic in PowerApps, Portals, SharePoint, etc

Let\’s see how this can be achieved.

Step 1- Initialize a variable to store Contact Record Count

Step 2- Retrieve Contact from CDS where email equal to \’arpit@dynamics.community\’.

I have hardcoded the email address in the fetch XML itself, however, you can pass it\’s value dynamically based on your business need.

Step 3- Calculate the Count/Length of all retrieved contact records.

Use the following expression to count the length of all retrieved contact records

length(body(\’Get_Contact\’)?[\’value\’])

Here \’Get_Contact\’ is the name of the previous step. If your previous step name is Get Account Records then you have to change this value to \’Get_Account_Records\’. 

Note: Space must be replaced with an underscore

Step 4- Use Count in Condition and Perform your logic accordingly

Step 5 – Test the Flow

Published by arpitpowerguide

My name is Arpit Shrivastava, who is a Microsoft MVP in the Business Applications category. I am a Microsoft Dynamics 365 and Power Platform enthusiast person who is having a passion for researching and learning new things and acquiring immense knowledge. I am providing consistent help, support, and sharing my knowledge through various Social Media Channels along with my Personal Blog, Microsoft Community, conducting online training and attending various 365 Saturday Events worldwide and sharing the best Solutions to the readers helping them achieve their goals and objectives in Customer Relationship Space.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: