As everybody else has already noticed, CRUD support has been added to the Virtual Entities:
A while ago, I blogged about how we can use canvas apps with virtual entities, and there was a sample plugin there:
https://www.itaintboring.com/dynamics-crm/virtual-entities-revisited-setting-up-a-virtual-entity/
So, I figured, I’d just try updating that plugin to support create/update/delete. Since it is, already, supporting Retrieve and RetrieveMultiple.
It seems this should be really simple. All the details about the virtual record are supposed to be passed through the “Target” parameter of the plugin context
- On “Create”, I should have the record being created there, as an Entity
- On “Update”, I should have the record being update there, as an Entity
- On “Delete”, I should have the record being delete there, but as an EntityReference this time
Updating the plugin did not take long, and you’ll see the code in git. Although, turned out I had to download updated version of the plugin registration utility, since, otherwise, there was no support for create/update/delete:
Actually, if you look at that screenshot above, there seem to be a remnant of how it used to work. There is still that note. That’s the past, we are in the present, so moving on!
Ok, let’s set it all up – I mean, let’s update data provide settings:
And click “update”… and there is an exception:
Not sure why that happened, but, apparently, registering a completely new data source worked:
Here it is, my new data source with a new data provider:
Why did it fail when I tried updating the original one? Not sure at the moment, but, with this new data source, I wonder if I can use it with the existing virtual entity. Otherwise, it would be a problem… so, let’s try that out.
Let’s go to the virtual entity configuration in the solution and pick the new data source:
Actually, that always gets me. There is no new data source. Not yet. First, we have to go to the Settings->Administration and create a new data source, even if that may sound a little counterintuitive. Did not we create a data source in the plugin registration tool? But we do have to add it to the list of Data Sources in the administration area – there are always these two steps involved:
Why do we need to define “data sources” in two different places? Not sure.
Now that it’s there, I can choose this new data source for my existing Virtual Entity:
Just had to add another main form (since the old one had that canvas app on it), and…
That’s a bummer. But… maybe, that “upgrade” path is not working yet? Let’s create a new virtual entity. An hour later, there is a new virtual entity and the plugin has been adjusted to fix a few bugs related to nulls, but, in the end, here we go:
It was, after all, a problem with the upgrade. Looks like that original entity has been somehow marked as “readonly” (might need to dig into the metadata, but that’s for another time).
I guess there are still limitations there (using advanced find, security roles, etc), but, with the CRUD support now… there is quite a bit more we should be able to use virtual entities for, eh?
PS. And here is a link to the updated date provider solution in git: https://github.com/ashlega/ITAintBoring.VirtualEntities