Count of total CDS records returned in a Canvas Power App connection [Quick Tip]

Like in Dynamics 365, you see a total number of records under a view. And you want similar in a Canvas PowerApp too.
undefined

Here’s a simple tip to do so –

CountRows() method

It’s pretty simple. Using CountRows(source) method, you can get the count of records in the Source. In this case, it’s the CDS entity Accounts.
undefined

To flourish how I display the count, I use the Concatenate() method and then use CountRows() inside it first show the text and then the actual count.

Please note that this goes without filtering out any criteria and straight count of how many records the connection has. Your gallery could use more filtering to display lesser records if specified that way.

Handle Delegation

However, you need to handle a few things if you’re aware that your dataset is large.

Using this formula will give a warning:
undefined

And the general help offered is this –
undefined

Refer this article to understand more: https://powerapps.microsoft.com/en-us/blog/powerapps-data-row-limit-for-non-delegable-queries/

Hope this quick tip helps!

Here are some more Canvas PowerApp / Power Automate posts you might want to look at –

  1. Dependent OptionSets in a Canvas Power App for 1:N related CDS entities | Power Platform
  2. Restore older version of a Canvas Power App | Power Platform
  3. Implement character length validation in a Canvas Power App | Power Platform
  4. Logged In User details in a Canvas Power App
  5. Implementing Exit app, Logout and Confirm Exit features in a Canvas Power App
  6. Variables in Canvas Power Apps | Global and Context
  7. Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
  8. Get Count of records retrieved in CDS connector in a Flow | Power Automate

Thank you!

BPF Flow Step as a Trigger in CDS (Current Environment) connector | Power Automate

Here’s an update to the Common Data Service (Current Environment) connector in Power Automate

Remember, this is available only in Common Data Service (Current Environment) connector i.e. you’ll need to create you Flow inside a Solution in Power Automate
undefined

Flow Step

Now, you can call your Flow from a Business Process Flow, which existed for some time. But now, it’s available as a trigger in the Common Data Service (Current Environment)
undefined

Flow & BPF Setup

  1. Now, my Flow is kept simple to illustrate what has been triggered. The first step simple is run When a flow step is executed.
    It starts with a simple Instant Flow like template if you want to have an additional input
    undefined
    And then you can use these in the context further. But I’ll keep it simple assuming you are familiar with trigger inputs.
  2. Then, you get the details that you can use from the trigger.
    undefined
  3. And I’m simply passing on the values over to an email so that I can read it. You application could be anything. Typically, it could be a complex business process in a Flow to trigger when a Flow Step is triggered.
    undefined
  4. Now, in my Business Process Flow Step, I’ve added a Flow Step (Preview), mind that this is still in Preview as of writing this post.
    undefined
  5. And select the Flow I’ve intended for this.
    undefined

Running the Flow

Now, here’s how it goes –

  1. I’ve called the Flow from the Flow Step
    undefined
  2. It’ll ask for confirmation of the Flow in a window
    undefined
  3. Once all the permissions are set, depending on what’s needed in the Flow, you’ll be asked for a confirmation
    undefined
  4. Once completed, you can check in Flow Runs about what happened to the execution of the Flow
    undefined


Results

So here are some results I composed from the data of the BPF itself-
undefined

And that’s it!

Here are some more Power Automate / Flow posts you might want to look at:

  1. Pause a Flow using Delay and Delay Until | Power Automate
  2. Generate Dynamics 365 record link in a Flow using CDS connector | Power Automate
  3. Text Functions in a Flow | Power Automate
  4. Loop through array of objects in a Flow & Create records in CDS | Power Automate
  5. Get Count of records retrieved in CDS connector in a Flow | Power Automate
  6. Number Formatting in a Flow | Power Automate
  7. Call a Dynamics 365 Action from Flow [Bound and Unbound Actions] | Power Automate
  8. Switch-Case in a Flow | Power Automate
  9. Setting Retry Policy for an HTTP request in a Flow | Power Automate
  10. Make HTTP request from Flow in Power Automate

Hope this helps!!

Generate Dynamics 365 record link in a Flow using CDS connector | Power Automate

There are several ways to formulate a Dynamics 365 record URL and make it clickable in a Flow in Power Automate.

Here’s one of the ways I follow for most scenarios – Let’s say I want to open a PSA Time Entry record from my Flow, here’s how I do it

Get record action to retrieve URL

Since this post is focused on CDS connector, I can get the D365 record link in body of Get record action for Common Data Service connector.

Unfortunately, I didn’t see this if the trigger was a CDS action, so I made a separate Get record call.
undefined

undefined
But, we’ll retrieve the same without having to select/parse body object. So let’s see –

Generating Link

First, I’ve initialized a variable that’ll hold the String format of the end URL
undefined
Now, first – I’ve appended https://. This won’t come directly using the uriHost() method

Then, the uriHost() holds the formula ‘uriHost(body(‘Get_record’)?[‘@odata.id’])

Meaning, get the uriHost name i.e. Environment name itself.
undefined

Then, I’ve appended options for the window to open which are mentioned below in this post.

Finally, I’ve appended the Primary Key of the record itself at the end
undefined

Options

Now, let’s talk about the options –

  1. cmdBar = [true | false]
    It’ll show the ribbon on the record. If false is chosen, it’ll be hidden
    undefined
  2. navBar = [off | on]
    It’ll show the Navigation Bar on top if on. If off, it’ll be hidden
    undefined
  3. newWindow=[true | false]
    This didn’t affect in my case. It anyway opened in a new tab. This could be different is the link is not opened from Email but is used elsewhere
    undefined
  4. pagetype=entityrecord
    Since we are targeting a Dynamics 365 entity record, the above is used.
    undefined
  5. etn= [name of the entity]
    Name of the entity
    undefined
  6. id
    GUID of the record itself.
    undefined

Here’s an Email that I composed to show how the URL will end up looking –
undefined

Which will result in Email like this

undefined

And open the record like this.
undefined
As per my settings in the URL I created, I don’t have the Nav Bar or Command Bar visible. It’s up to you to decide your preference

Here are some more Power Automate / Flow content you might want to check –

  1. Text Functions in a Flow | Power Automate
  2. Loop through array of objects in a Flow & Create records in CDS | Power Automate
  3. Get Count of records retrieved in CDS connector in a Flow | Power Automate
  4. Number Formatting in a Flow | Power Automate
  5. Call a Dynamics 365 Action from Flow [Bound and Unbound Actions] | Power Automate
  6. Make HTTP request from Flow in Power Automate
  7. Switch-Case in a Flow | Power Automate
  8. Setting Retry Policy for an HTTP request in a Flow | Power Automate

Hope this helps!!

Loop through array of objects in a Flow & Create records in CDS | Power Automate

One of the most common scenarios that are looked out for are ways to loop through an array of objects received (say, from HTTP response) and create CDS records

Sample Data

Let’s say this is the sample data coming in which is an array of objects. This is coming from my HTTP trigger which I created and hosted. It could be anything else in your case
undefined

And the body looks something like this –

[{"Name":"FreshBeans Coffee","City":"Mumbai","Phone":999999999},{"Name":"Timber Mart","City":"Pune","Phone":999999999}]

Generate Schema from Payload

I need to first create the Schema to be able to easily read from the JSON response
undefined

Paste a sample Payload in the dialog box
undefined

And it will generate a Schema
undefined

And when this is generated, you can access the attributes further in your Flow
undefined

What if you just enter a blank object and not generate from Schema or enter Schema explicitly as shown below –
undefined
You won’t get the attributes from the JSON Payload which is needed further
undefined

Loop through array and Create in CDS

Now, you can use Apply To Each and pass the Parsed JSON Body. I’ve simply used Compose to see the entire Object while checking results (No other purpose of using Compose in this example)
undefined

And then the next step is to Create CDS records from the looped Objects. So, since I have the schema generated above, I can use the attributes to directly map it to the CDS Create Record action

undefined

Running the Flow

Finally, once I run the Flow and check the actions performed. I’ll create 2 records since there are 2 objects in my array.

I’ll see the Compose step to see what I got in the object. As I mentioned earlier, this is not required- I just intend to put it there to see what data came in
undefined

And the Create Record in CDS step will create record in my Dynamics 365 environment as I intended it to do –
undefined

I can check the same in Dynamics 365
undefined

You might also want to check other posts related to Power Automate –

  1. Get Count of records retrieved in CDS connector in a Flow | Power Automate
  2. Number Formatting in a Flow | Power Automate
  3. Call a Dynamics 365 Action from Flow [Bound and Unbound Actions] | Power Automate
  4. Switch-Case in a Flow | Power Automate
  5. Setting Retry Policy for an HTTP request in a Flow | Power Automate
  6. Make HTTP request from Flow in Power Automate
  7. Button Flow in Power Automate to replicate a Quick Create Form in D365 CE
  8. Enable Flow button on D365 Ribbon

Hope this was easy!

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!

Using Parse JSON to read individual List Records in Flow|Power Automate

This is a scenario I came across when I was using Common Data Service connector [not Common Data Service (Current Environment)] connector to read Opportunities tied to an Account.

Example

In this scenario, I wanted to retrieve the Opportunities tied to an Account. So, my filter query was _parentaccountid_value(‘ACCOUNT_IDENTIFIER’)

Here’s my Flow starts. I want to read Opportunities that are tied to my Account in context –

baseQuery

Flow Inside a solution vs. Outside a Solution

Inside a Solution

Now, when I had this Flow inside a solution, the result didn’t have a body and instead just gave me Status Reason value as below –

missingData

Outside a Solution

Whereas, outside the Solution, I was able to get the array of Objects i.e. Opportunity data in the Body in the Output itself.
outsideSolutionResult

So, what can we do about the Flow which is used inside a Solution and you want to actually see what was the output? You may or may not require to see the records (depending on your implementation)

But let’s say you want to see what was returned, let’s just parse these results as is using Parse JSON to see what we got.

Use Parse JSON from Data Operation

Another way to read what you’re retrieving is using Parse JSON Data Operation.

  1. Search Parse JSON and you’ll see the result in Data Operation type of Actions as shown below –useParseJSON
  2. Now, you have to apply this to Current item from the retrieved List records in Apply to each operation. In case you don’t have the schema or not sure what to put it in. Simply use {} in Schema field. This will just pass through as is.
    applyParseJSON

Checking Result

Now, let’s test using the above and see if we can get the results

  1. Now, you can actually see the Inputs and Output of Parse JSON which is basically the same. This is useful if you want to visually see what’s going on through your Flow.
    visibleResult

But, if you don’t want to see what’s being passed through when in Production? You can Secure Input/Output in Power Automate Run History

Hope this helps you!!

AutoNumber field in CDS | PowerApps

The most desired feature is ability to create/customize your own auto-number field. ANd CDS let’s your do just that!

I remember the good old days when I had to write a plugin to function for AutoNumber which used to configuration from a supposedly separate Configuration entity and it scary to maintain the code and entity. But this solves all that with so much ease!
allRecords

 

Create an AutoNumber field in CDS

  1. Now, you can start by creating a field in CDS’ Solutions > [YourSolution]> [YourEntity]
    createNew

  2. Then, under Accounts, you can see that you can actually create an Autonumber. This is not available in Classic UI.
    Also, please note that you’ll need to keep this field Not Required and Locked (on the form) in order to function.
    underTextGroup
  3. Give it  a suitable name and then you have 3 options to format your auto-number field.
    2TypesOfAutonumber

    String Prefixed number

    You’ll need to define the Prefix, Min Digits, Seed value
    preview

    Date prefixed number

    With Date prefixed, you’ll need to define Date Format, Min Digits of Seed Value
    dateFieldPreview

    Custom

    With custom, you can define the Format. Refer Microsoft’s Documentation for the same – AutoNumberFormat options
    customPreview

Save and Publish as you usually would and place your field on the form you want.

Working

I used String method to design my AutoNumber field. Let’s see how it looks –
Once I save the record, the Auto-number will be filled in.
fieldWorking

If you happen to delete any records already created in the sequence, the auto-number functionality will continue counting upward and not fill out previous backlogs/last deleted auto-number records.

 

Hope this helps!

Create new Sandbox and copy Production over to it in PowerPlatform Admin Center

This is one of the standard approaches if you want to copy over a Production instance over to a Sandbox one. Most common scenarios being when you’ve on-boarded a new client to Dynamics 365 / PowerPlatform and you’re nearing Go Live for the first time!

You need a Sandbox to then follow new customization on the Sandbox and avoid doing anything on the Production. Here’s how you copy over from Production to Sandbox!

 

Creating a Sandbox

  1. Create a new Environment by clicking on the +New button as below
    newButton.png
  2. Now, you can directly create a new Sandbox environment in the PowerPlatform Admin Center (https://admin.powerplatform.microsoft.com/environments)
    Remember: Both the source and target environments need to be in the same region to copy.
    createSandbox.png
  3. Additionally, I’ve selected the Create a Database option too since I want to speed up the process.
    addingDatabase.png
    Note that you can chose which all apps you want to deploy if you chose Enable Dynamics 365 apps

And that’s it. You’ll need to wait for some time until this is processed!

If you’re also looking to create a Database explicitly for an existing environment using a previous method, you can check this post – Create new CDS Environment and Database quickly from PowerApps Admin Center

While this happens in the background, you can see the message on the Environments section on the Power Platform Admin Center
preparing.png

 

And upon completion, you’ll see the below message
completedCreation.png

Copying From Production to Sandbox

Next step is to copy over the Production to the newly created Sandbox environment.

  1. Select the Production environment you want to copy over and look at the ribbon, you’ll see a copy button.
    copyButton.png
  2. Once you click on the Copy, you’ll be asked about the target environment, chose the created Sandbox.
    selectTarget.png
  3. Once you confirm, the copying process will start. And you’ll be taken to this page which tells you what stage the process is in –
    currentProcess.png
  4. Once all the copying is completed, this notification will appear. Now, the next step is to turn off Administration Mode. Click on settings link as shown below by arrow.
    copySuccess.png
  5. Once you flick the switch and Save, Administration Mode will be disabled letting others to log in as well. Additionally, now we have the option to keep Background Operations On as well while keeping Administration Mode On as well.
    disableAdminMode.png

Now, you are all set. Hope this helps!