Filtering the ‘Regarding’ column in Power Automate

What is the ‘Regarding’ column?

In the world of Dynamics 365 and model-driven apps there is a magical lookup found on all ‘Activity’ records called “Regarding”. A simple lookup can only link a record to one table e.g. an Opportunity or an Account. The regarding column is magical because it allows you to link the activity to many different tables (so long as they are enabled for activities) so it is a “a single reference to multiple tables“.

More information on lookup types -> Types of fields and field data types | Microsoft Docs

More information on lookup types -> Types of fields and field data types | Microsoft Docs

PS. if you are impatient/lazy and don’t want to scroll - this is the magic password

triggerOutputs()?['body/_regardingobjectid_type']

The challenge

I want to be able to trigger an automated Cloud Flow in Power Automate when an email is tracked ‘Regarding’ an Account record in Dynamics (or Dataverse). So I go to FetchXML Builder and get it to build me a snazzy oData filter for this - great!

OdataQuery.png

So the filter is set like so:

(regardingobjectid_account_email/accountid ne null)

However, when I add this snippet into the ‘Row Filter’ - Save and exit from the edit screen to the details screen - the flow checker is not happy! “There’s a problem with this flows trigger’… select ‘Go to the trigger’ and there’s a juicy error message which doesn’t make much sense to me but it does not like the second section of the filter “Exception parsing (regardingobjectid_account_email/accountid ne null)”

FlowChecker.png

Step 1: Simplify the filter

SimpleRowFilter.png

Let’s strip the filter back so we only filter out records which have Regarding populated (not ideal but its better than triggering on every single email)

(_regardingobjectid_value ne null)

Step 2: Check the output of ‘Regarding’ value/type

RegardingValues.png

Using a compose action we can set the flow outputs to show us the values coming from Value And Type from the Sender. The variables are there to use - but the Type is coming back blank. Hence the flow trigger failed when we tried to filter on the Sender type.

RegardingOutput.png

Step 3: Ask for the Regarding (Type)

So how can we ensure our flow only does the proceeding actions when the email is Regarding an Account? Ask again!

MagicType.png
 
triggerOutputs()?['body/_regardingobjectid_type']
MagicTypeOut.png

Step 4: Check your homework

Let’s see the magic in action. Add an ‘If’ condition step (or a switch statement perhaps) and then flow through to the right action based on the regarding type - by using the compose steps again we can see what the Regarding (Type) is coming out as at the other end.

Check your homework.png

Finish: Winner Winner Chicken Dinner!

HomeworkCheck.png
Email reagrding Account.png
EMail reagrding Leadf.png

Bonus tip

There magical powerful lookups can be tricky, ‘Regarding’ is not the only one either. I stumbled on the similar issue when working with the ‘From’ field on an email - maybe for a future post but basically follow the same pattern above but the magic code in step 3 is this

triggerOutputs()?['body/_emailsender_type']

The moral of the story

When you are using Power Automate trigger ‘When a row is created, updated or deleted’ - the rules are as follows:

  1. Ask once and you will be rudely blanked

  2. Ask again and you shall receive

  3. Resilience is your best weapon

Go forth and filter!

P.S. I hope you enjoyed the modern day lorem ipsum - ‘Online Dating Ipsum’ content in the emails 😉
Online Dating Ipsum | Filler text for your very attractive and interesting projects (laurenhallden.com)

Previous
Previous

Favicon - Transform your Dynamics Marketing Event Portal

Next
Next

Register now button - Transform your Dynamics Marketing Event Portal