A colleague asked me a question earlier today (I can probably use this theme for half of the posts here… for that matter, do you have a good question? Feel free to ask ):
“why is this Flow condition on regardingobjectid type not working?”
And the condition looked more or less like this:
(It’s truncated on the screenshot, but it’s “Regarding(Type)” in there)
At first, I was like “no big deal, there is something wrong with the Flow”. So, I tried to create a manual Flow which would pick a task and would have the same condition there. The same condition in this Flow actually worked fine!
And, of course, I said “see… it’s definitely something with the Flow”. But I kept thinking to myself it’s unlikely this particular colleague would make a rookie mistake somewhere, so… I tried a Flow that triggers on create of a Task. And you know what?
The same condition in this new Flow did not work!
Let’s dig into it a little more, then?
Here is the Flow that worked:
The reason I had “Compose 4” step is that I wanted to see the json payload. Here is what I saw:
There is this particular line in the payload, which actually makes the difference between my two Flows:
“_regardingobjectid_value@Microsoft.Dynamics.CRM.lookuplogicalname”: “account”
The other Flow (which is triggered when a new task is created) did not have all those nicely expanded properties:
See how the only thing we really know about _regardingobjectid_value is the id? Which is exactly why my condition works in the Flow when I’m selecting records from CDS in a separate action, and it does not work when the Flow is just responding to a trigger.
Since here is how those Flows are trying to access regardingobjectid type:
That information is just not available in one of the Flows (the one which is triggered when a new task is created).
Well, now that we know what’s happening, how do we handle this?
I see a couple of options how to make this work in the Flow that is triggered by a new task:
a) We can use the following expression:
triggerOutputs()?[‘body/_regardingobjectid_type’]
That produces the following output:
Notice that it’s “accountS”, not “account”. This will work for the condition, but it’s sort of inconsistent with the conditions we need to use for the tasks which are queried from CDS within the flow. Those actions won’t have regardingobjectid_type in the output (I checked, but I would encourage you to double-check).
b) We can add “Get Record” action right after the initial trigger, and we can work with the output of that action instead
Essentially, this turns it into a Flow which works with the records queried from CDS rather than with the records which came in through the trigger, and it just works as it should:
PS. In retrospect, my original thought proved to be correct, btw. It was something with the Flow, just it was not the way I thought it would be
Nice work Alex! MS should document this quirk.
Could you apply the same concept in tracking all incoming emails with set-regarding
and performing some other actions
I’m eternally grateful for this post. Two hours of my life I’ll never get back