Full disclaimer… this post was triggered by what a fellow MVP, Olena Grischenko, wrote earlier today: https://msolenacrm.blog/2020/06/18/power-automate-for-cds-what-was-it-before-we-run-the-update-or-byebye-no-code/ 

I am all for plugins, I actually write them every daySmile But, then, should not there be some way to work with pre/post images in PowerAutomate? Without code?

And there is one, although “no code” solutions are not, always, the easiest:

image

Basically, we can set up CDS to send pre/post/target data to a queue in Azure Service Bus. It’s not a complicated process, you just need to follow the steps described here:

https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/walkthrough-register-azure-aware-plug-in-using-plug-in-registration-tool

Just make sure to use json message format when setting up the integration:

image

Once that is done, you can start adding SDK steps. And, for those SDK steps, you can start adding pre/post images:

image

Let’s say that’s been done.

The next step would be creating a flow. PowerAutomate has a connector for Azure Service Bus:

https://flow.microsoft.com/en-us/connectors/shared_servicebus/service-bus/

So, set up the trigger:

image

The remaining part is all about parsing that json from the message queue. Unfortunately, there is no “native” regex capability in Flows, though there are a few third-party connectors there. I did not try those, pretty sure they would work, but this is where “no code” is not the same as “no fees”Smile

Instead, I just opted to tweak the regex custom connector which I blogged about some time ago:

https://www.itaintboring.com/dynamics-crm/custom-connector-where-powerautomate-finds-peace-with-logic-apps/

Here is the code I used for the regex action this time:

image

Now, once there is a regex connector, I just need to add a couple of action to extract “name” field from the pre image:

image

And, also, to extract it from the post image:

image

This is where you may have to look at the json and figure out how to write that regex expression (might need to test it in the regex tester).

Once that is done, I can access both pre-image and post-image values of the “name” attribute. In my case, I simply sent an email to myself:

image

And, once the email came in, both value are there:

image

What are the caveats?

  • We need to create azure service bus queue
  • We can’t rely on the capabilities of the CDS connector. Although, plugin registration tool is a powerful tool, so this is really a problem for the next step
  • Since we do need to figure out how to parse that json

But, in either case, except for the regex connector, this is a no-code solution to the problem. Might actually be possible to just use a bunch of “substring” and “indexof” function calls to do the same, but it’s probably easier to just set up that custom regex connector (or to subscribe to one of those which are already available in Power Automate)