[email-IV] Automatic Record Creation Rules actions

In my previous post, I introduced the new Automatic Record Creation rules in the Customer Service Hub app. In this new post, I’m going to expand this topic to use conditions and actions. This will allow us really to generate other records and I’ll show you an example to group emails by case.

I have just added a new action called “Create case for any email”:

This action doesn’t have any condition, so initially it allows any type of email, and it should just create a case:

So now the question is, when would a new case record be actually created? Here are some test cases I have run:

  • An outgoing email created from Dynamics 365, added to the monitored queue and sent
    • The queue item is deactivated when the email is sent
    • Power Automate flow is NOT triggered
    • No case is created
  • An incoming email is received from an unknown sender
    • No contact is created
    • Power Automate flow is triggered
    • No case is created
  • An incoming email is received from a known sender
    • Existing contact is reused
    • Power Automate flow is triggered
    • A new case is created

You can see the actual definition of the Power Automate flow by making click on “Save and open Power Automate” (see previous screenshot):

Let’s analyse each one of those steps:

This first step is the trigger. Notice it is initiated by an update event on the importsequencenumber attribute. I found this interesting, being a simple mechanism to trigger the flow asynchronously only when this field is updated. The key question is “who/what is updating this attribute then?”

The second step initialises a variable for the email sender and check the sender type.

If the sender is not a contact or an account, the flow is cancelled. Otherwise, it will continue and retrieve the corresponding existing record:

Then it will create a new case record using the identified customer (contact/account) record. Notice how the subject of the case is the same as the email. You could now customise this as well as other details in the new case record:

Finally, the flow executes the action “msdyn_ExecutePrimaryCreatePostActions” 🤔 with the email and case records as parameters:

So what is that actions doing? We can actually find it in the Default Solution of our environment and see the details:

If you search by “ExecutePrimaryCreatePostActions” (remove the prefix “msdyn_“), you will notice two components. The first component is a Process, which is the actual action. The second is a plug-in step running the actual logic of the action.

As you can see, no logic is defined in the actual action because it is delegated to the plug-in step. Can we look at the code in that plug-in? Sure 😊, using the utility Assembly Recovery Tool in XrmToolbox we can download this assembly and then use ILSpy to understand its code:

The plugin is running a couple of tasks:

  1. Set the regarding in the email activity to the new case record
  2. Send a reply email with the configured entity.

This second task is optional and the reply email is only sent if we configured it initially as part of the rule:

As you can see, the Automatic Record Creation rules have a decent amount of logic behind and they can provide some great value without development effort.

Please notice this is the system information at the time of this post:

  • Environment with Customer Service and Sales Enterprise Dynamics 365 apps enabled
  • 2020 release wave 2 enabled
  • Server version: 9.1.0000.25547
  • Client version: 1.4.1809-2011.1

One thought on “[email-IV] Automatic Record Creation Rules actions

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