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
No comments:
Post a Comment