Design a site like this with WordPress.com
Get started

LEARNING POWER AUTOMATE – Handle Flow Trigger

As we all know that Microsoft Flow is also known as Power Automate.

So, it has some limitations as well. Like Request limit, Flow limits, etc. to know more about Limits and configuration in Power Automate,, click here.

Another important point about power automate is that it is priced based on the number of times the flow has been triggered.

So, today we will learn how can we restrict/filter our power automate trigger.

Here is the scenario, I have a custom entity(Blog Note) of activity type and I want my power automate to trigger on create of blog note record when it’s is created from the Contact entity.

Now, under the timeline section, I can see an extra activity entity named Blog Note under Account, Contact, Lead, and so on.

I have the power automate ready with me, which triggers whenever a record is created within the Blog Notes entity from any entity like account, contact, lead, and so on.

I want to restrict my flow run so that it triggers only when a user creates the blog notes from the Contact entity. If a blog notes is created from some other entity like account or lead then the flow should not trigger.

To handle this we need to go to the trigger step(Trigger on create of BlogNotes) setting.

Go to – trigger step Settings
Added the Trigger Condition

This is how we check if the regardingid is a contact entity then only the power automate trigger else it won’t.

I hope this helps!

Advertisement

Learning Power Automate – Check null for a variable

Today, we will learn how to check an empty value on a variable under Power Automate.

I had a requirement where I need to push my Lead record data from Dynamics CRM to another application.

To fulfill this requirement, I thought of going with power automate. Which would trigger whenever a record is created under the Lead entity and then push the data to another application.

Here I have a field Due Date which is an optional field on a form. So now it is a user who chooses to enter data or not.

I have a child flow where I need to pass the data of Due Data as well. Below is the JSON schema for Child Flow. We can see that the due date is of string type, therefore if we pass null value it would throw us an error: Invalid type. Expected String but got Null

JSON Schema

To handle this scenario, we can use an empty expression:

Expression:
syntax: if (empty(duedate), ”, duedate)

expression used to check field(duedate) was empty:

if (empty(string(triggerOutputs() ? ['body/duedate'])), '', triggerOutputs() ? [' body/duedate'])

How the expression work is it checks whether the field is empty or not, which means if the value is null or empty then it returns true which will pass not null. This is accepted as a string. Else, if the field contains a value then it would pass the field value.

Hope this help!

Learning PowerAutomate – Get Option set label

Let’s learn how to get option set label, without query to string map table for retrieving the labels.

As, we know that querying to an entity option set field will give us the option set value not the label. So if we want to get the option set label against any value

Note*: we can use an expression to get option set labels.

I have an option set attribute named as Loan type, which is present on Lead entity.
Querying on Lead entity, for attribute Loan type. I get the option set value not the label.

Therefore, to get the label against the retrieved value. I went using replace expression:

replace(replace(replace(string(triggerOutputs() ? ['body/new_loantype']), '43260000', 'HomeLoan'), '43260001', 'BusinessLoan'), '43260002', 'PersonalLoan')

The expression replaces the option set value with the given label.
Example, whenever we get the loan type as ‘43260000’, using the expression I will get the result as “HomeLoan”.

Moving ahead, we can use the set variable step under our flow. Where we can use the expression based on the output we receive for the above steps.

Additionally on top of the above requirement handling process, I went into another scenario where the option set field was coming null.
Reason, the field was marked as optional field. So, now its a user choice to enter data for option set field or leave it as null.

So, whenever I was getting the null value for the option set field records, I was getting an error as: Invalid type. Expected String but got Null.

Therefore for handling the null value exception, I went using empty expression:

if(empty(string(triggerOutputs()?['body/new_loantype'])),'',replace(replace(replace(replace(string(triggerOutputs() ? ['body/ new_loantype']), '43260000', 'HomeLoan'), '43260001', 'BusinessLoan'), '43260002', 'PersonalLoan')

The above expression helps us in handling null value. When we are passing loan type value to another variable of string type or to a child flow when the expected schema is of type “string”.

I hope this helps anyone! 😊

Calculate Age using Power Automate

Today, let’s learn how to calculate a person’s age using Power Automate.

There are multiple ways to calculate a person’s age. The DOB field which I have is of string type. So, I thought of using Power Automate to achieve this.

Search for Common Data Service and the trigger should be When a record is created, updated, or deleted as shown in the below image. Next, enter the required details like the environment and the entity name.

Figure 1: Selecting trigger for this flow

Then we will add a condition to our flow, where we will check whether the Date of Birth field is null or not.

Figure 2: Check Date of Birth field is null or not

If the Data of Birth field is not null then we will calculate the age. For that when the condition is met the flow would go under IF yes condition, where we will have to provide the entity name and field under which the calculated age needs to be populated.

Figure 3: Mapping of entity under which the calculated age value to be populated
div(div(sub(ticks(utcNow('yyyy-MM-dd')),ticks(triggerBody()['new_dateofbirth'])),864000000000),365.25)

We will use the above expression for calculating the age. 
Place the cursor inside the Calculate Age field and paste the above expression under the expression section and click on the Update button.

Figure 4: Using expression for calculating value.

Now, we need to test our flow. Hit the Test button on the right top of your screen.

Figure 5: Test Flow

After a successful run of the flow. We can see age would have been populated under the Calculate Age field under the Contact entity.

Hope this helps anyone !!!

Retrieve data from Azure Cosmos DB using Power Automate

Let’s learn about how to fetch data from Cosmos DB using Power Automate and push into Dynamics CRM.

For retrieving the data from Azure Cosmos DB we will need a few details from Azure:

1. URI
2. Primary Key

Figure 1: Azure Key for Cosmos DB connectivity

Let’s jump to Power Automate and start adding the necessary component for achieving this activity.

I have used a manual trigger for reading the data from Azure Cosmos DB and pushing it into Dynamics CRM.
Chose an action –> Search for Azure Cosmos DB, then under action select Get all documents.

Figure 2: Creating Flow using Azure Cosmos DB component

We will use the Azure Cosmos DB detail for establishing the connection as shown in the below image. Access Key to your Azure Cosmos DB account here we have to enter Primary Key as shown under Figure 1. Hit Create button.

Figure 3: Establishing connection with Cosmos DB
Figure 4: Select the DB and table

Select the desired database under the Database ID and table under the Collection ID field and hit the + New step button.

After the connection has been successfully established. Search for Parse JSON and add Documents under the Content field. Paste the JSON output under the schema. Hit the + New step button.

Figure 5: Parse JSON as an output

Next, we will search for a control Apply to each.

Figure 6: Add control Apply to each

Under, Select an output from previous steps field pastes the Body from the Dynamic content and click Add an action button.

Figure 7: Add Body from Dynamic content
Figure 8: Search for Common Data Service(current environment), Action: Create a new record

The above action is needed as it will allow us to map the value coming from JSON to be stored inside Dynamics CRM entity attributes. 

Figure 9: Mapping CRM attributes with the output columns.

Now, we need to test our flow with a few more clicks to be performed. Click on the Test button which would appear on the right top of the screen.

Figure 10: Test Flow

The flow will start executing, once the flow has run successfully we will get the below screen. 

Figure 12: Flow execution

Now, go into CRM and we will see the records have been created under the expected entity.

Hope this help anyone!

Create first Microsoft Flow

Starting with flow you need to have 3 thing in your mind.

  • Template – Decide the template which would be used for the flow.
  • Trigger – Event which would trigger the workflow.
  • Actions – Set of actions which will be performed when the criteria are met.

Login to Microsoft Flow site.

Figure 1: Login Page

Scrolling down the page you will find few sets of services. If the service for which you are looking for is not present in the list, click on See all option. This will navigate you to the page where you can find all the services which are currently present with Microsoft.

Click on the service and select the template.

Figure 2: Choose Service


If the required template is not present. You can create your template from My flows.

Today I am going to create a flow which will send an email notification whenever an account is created in Microsoft Dynamics 365 application.

Figure 3: My Flows tab
Figure 4: Create a new blank flow

Clicking on Create form blank option will redirect you to the page where you can find multiple triggers. Choose a trigger to get started with the flow.

Figure 5: Choose the trigger

Select the CRM Organization under Organization Name field. This will populate all the entities respective to the selected organization under Entity name field.

Choose the CRM entity under Entity name. The flow would only trigger whenever a record is created under the selected CRM entity.

Figure 6: Choose the Organization and Entity

Click on add New step button.

Figure 7: Click New Step for adding another Trigger.

I am going to receive email notification on my outlook account therefore I am searching for Outlook, select the mail option Outlook.com

Figure 8: Search Outlook

Now, select Send an email option for sending the notification when an account is created in CRM.

Figure 9: Choose Send an email

Enter the Email address in “To” field which would get the email notification for every Account which gets created in CRM. Enter the Email Subject in the “Subject” field.

Microsoft flow provides you the ability to add the dynamic content by clicking on the Add dynamic content option as shown below:

Figure 10: Add dynamic content

Click on Show advanced options and select Yes under Is HTML field.

Figure 11: Select Show advanced option
Figure 12: Select Yes under Is HTML drop down

Go to mail Body and enter the text as shown in the below image:

<A href> tag is used for specifying a link destination. For now, I have provided the link of CRM Organization. Clicking on the link with navigate you to CRM homepage.
<A HREF= ‘https://orgname.crm8.dynamics.com/main.aspx’>Click Here for details</A>

Figure 13: Prepare mail body
Hello Team,
Account AccountName has been created in CRM.
Please verify and approve it.
<A HREF= 'https://orgname.crm8.dynamics.com/main.aspx'>Click Here for details</A>
Regards,
CRM Team

Now here is a trick for opening CRM record directly from the mail.

Login to CRM, open Account record. Get the Account record URL.

You would get the URL like the below URL which would contain the record GUID.

Figure 14: Account Record URL

Replace the Account GUID by adding dynamic content Account (which contain the Unique Identifier of Account). Please refer the below screenshot.

 'https:// orgname.crm8.dynamics.com/main.aspx?etc =1&extraqs=&histKey=675913679&id =%7bAccount%7d&newWindow=true&pagetype=entityrecord#799476899' 
Figure 15: Add Account Unique Identifier in mail body

Click the Save button and then hit the Test button for testing the flow.

Figure 16: Click Save and Hit Test

Select the option as I’ll perform the trigger action. Click Test.

Figure 17: Click Test button

Go to Dynamics CRM and create a new Account.

Figure 18: Create Account in CRM

Navigate back to flow and Check the flow status.

Figure 19: Check the Flow status

Login to Outlook.com and check there should be an email in your Inbox.

Figure: Mail received in Outlook inbox.

Clicking on Click Here for details hyperlink will navigate the user to CRM Application and open Apple Inc. account record.

Introduction to Microsoft Flows

What is Microsoft Flows ?

Microsoft Flow is a cloud-based service which helps to create workflow for automating the business process. These workflows are called as Flows.

Why use Microsoft Flows?

Microsoft Flow not only allows you to get integrated easily with any Microsoft products but also provide the ability to connect with the wide range of different products like Saleforce, Facebook, Twitter, Campfire, Gmail etc and many more.

Microsoft Flow by default come with multiple connectors which helps in creating workflow in very minimal time. It also gives you an ability to go ahead and create your own connectors.

Microsoft Flows can serve in many different ways. Like sending notification, Copying File, Collect Data , Collect Tweets and many more. Flows can be managed easily from desktop or mobile app.

How Microsoft Flows works?

For creating a flow, you need to know the trigger event and the set of actions which are required to be performed when the criteria is met.

The most common use of flow is to trigger notification on a specific event.
Example: Whenever a Lead or Account is created in CRM then a notification should be sent via text message or email to the sales representative. This could be achieved easily by Microsoft Flows through connectors.

Connectors are basically the API proxy which helps the services to connect with flows.