Wednesday 27 February 2019

Flow Condition Builder - How To's for Dynamics 365 and CDS

21:39 Posted by Benitez Here , , , , , , No comments
The Flow Condition Builder was released a few weeks ago and Stephen Siciliano announced it on the Flow Community site. I took it for a test drive to replicate what we are already familiar with in Dynamics 365 workflows. In this WTF episode I share the techniques in Flow because I want to help you with your learning to come up to speed with the new Flow Condition Builder.

Introducing the Flow Condition Builder

The following can be performed more easily now in Flow rather than using expressions as covered in my WTF Episode 2 blog post
  • AND
  • OR
  • group OR and AND statements

One thing I like that is not available today in Dynamics 365 workflows is the ability to move your criteria up and down, whether it's by a single field or a group.


The edit in advanced mode is no longer available however you can still use expressions within the Flow Condition Builder.

Referencing a lookup field

This is one of the most common conditional checks when configuring Dynamics 365 workflows. In the following screenshot I am checking that the Customer of a Case equals a particular Account record.

This was covered previously in my WTF Episode 2 blog post. To reference a lookup field in the Flow Condition Builder is straight forward. You select the lookup field, followed by the operator is equal to and paste in the GUID of the record.

Combining referencing a related entity field and contains data

Related entity field

If you want the criteria of your condition to use a field from a related entity and check that it contains data, the following is what we are familiar with today. In this screenshot I am checking that the selected Account in the Case has a Primary Contact. In other words the Primary Contact contains data.


If it does contain data, a Task will be created for the Owner of the Case to notify the Primary Contact that a Case has been created.

To do reference a related entity field in Flow you need to use the Get Record action which I covered in my WTF Episode 7 blog post. If you try search for the field in the Dynamic Content of the Flow Condition Builder you won't be successful because you have not provided the related entity for Flow to reference, it will only display fields from the entities currently referenced either in your trigger or preceding actions.


The Get Record action allows you to retrieve information from a N:1 related entity in the same manner that you're familiar with in Dynamics 365 workflows. In the following screenshot I am retrieving the Account record that is selected in the Customer field of the Case.


Now I can select the Primary Contact in the Dynamic Content of the Flow Condition Builder.

Contains Data

As mentioned earlier, the edit in advanced mode is no longer available in Flow which was what I covered in my WTF Episode 3 blog post. In the Flow Condition Builder you can now select operators instead of writing the expression which was the previous method. However you'll notice that there is no Contains Data or Does Not Contain Data which is what you're familiar with today in Dynamics 365 workflows.


To achieve Contains Data or Does Not Contain Data you need to use the function of null in an expression.


For Does Not Contain Data, the operator to select is is equal to


For Contains Data, the operation to select is not equal to


Ta da - now you have achieved referencing a related entity field and Contains Data.

Activity Count Including Process

If you're not familiar with Activity Count in Dynamics 365 workflows, I recommend reading fellow MVP Feridun's blog post. The one I am replicating is Activity Count Including Process because it doesn't make sense to me to only count activities that were not created by Dynamics 365 workflows.

In the example I demonstrated in my vlog, I'm checking the number of activities against a Case I've selected. 


Since activities is a 1:N related entity, there are multiple records to be checked. The CDS action to use is List Records which will allow you to query the activities against the case. 


I briefly cover List Records in my WTF Episode 9 blog post so check it out if you want to know more about the List Records action.

After you have configured your List Records action the next step is performing a count against the action. To do this use the Compose action and an expression. The function to use in the expression is Length and is described by another MVP Fautso in his blog post,

 This function returns the number of items in a string or an array

The List Records action will provide a collection of activities that are associated against the case. When using the Length function in an expression the output will be the number of records returned in the list.

In my example, the expression I used is length(body('1.2_List_activities')?['value'])


The next step is to use the Flow Condition Builder where you can specify your criteria. In my example I used the following

  • Check that the length output (number of activities) is greater than or equal to 1
To demonstrate the Yes and No paths, I used something simple where a Note was created for each path that indicated the number of activities against the case.

Summary

The Flow Condition Builder allows you to replicate most of the functionality you are familiar with today in Dynamics 365 workflows. There are actions and expressions that you'll need to use where relevant. I hope this helps you with your learning and understanding the Flow Condition Builder in the context of Dynamics 365 and CDS.

Post a tweet to let me know if this has helped you or if you've used any of the techniques mentioned in here.

If you think there can be improvements made to the Flow Condition Builder, please head over to the Flow Community Site to submit your idea.

Thanks and till next time, toodles!

0 comments:

Post a Comment