Virtual Entities Revisited: using embedded canvas app for updates

By | December 6, 2020

As you could see in the first post of these series, virtual entities are still alive, Microsoft itself is relying on them for integrations, and we can also do some interesting things with them.

In the second post, I walked you through the process of setting up a virtual entity and creating a custom provider.

The only remaining part which has not been covered yet is turning virtual entities into a first-class citizen of your model-driven app by adding “update” support. And, for that, embedded canvas apps are almost a perfect fit. Well, as long as there is a connector, of course. Which is exactly the case for the virtual entities sourced from SQL.

So… I’m assuming you are familiar with embedded canvas apps – will just mention a few things, then.

1. Screen size and scale to fit

Unless you want font sizes to keep changing as the user is resizing browser windows, disable scale to fit and set custom screen size.

image

2.  Enhanced SQL connector – disable it

image

Or you can try keeping it enabled (which is the default). However, if you start getting “Bad Request” on update of the SQL data, you might have to remove all SQL connectors from your app, disable that setting, then re-add SQL connectors.

3. Add controls and “Save” button to the app

image

image

Add a formula to Patch SQL data source on select of that “Save” button:

image

And use it to refresh model-driven form, too (with a call to ModelDrivenFormIntegration.RefreshForm)

The end result should look more or less like this:

image

Unfortunately, we can’t get rid of that “Read-only” warning at the top, but, well, that’s not too bad.

But, before we wrap it up, I just realized that I missed something in the custom data provider. For the embedded canvas app to work properly, the filtering part in the plugin had to be somewhat more complicated. So, make sure to revisit the part where I was describing custom data provider since there are a few changes there.

PS. As a bonus, since you’ll be revisiting… Notice that I’ve also moved connection string to the secure configuration of the plugin step, so it’s not hardcoded anymore.

Have fun!

Leave a Reply

Your email address will not be published. Required fields are marked *