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“.
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!
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)”
Step 1: Simplify the filter
(_regardingobjectid_value ne null)
Step 2: Check the output of ‘Regarding’ value/type
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!
triggerOutputs()?['body/_regardingobjectid_type']
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.
Finish: Winner Winner Chicken Dinner!
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:
Ask once and you will be rudely blanked
Ask again and you shall receive
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)