
We are migrating from CRM on prem to dynamics 365 and need to change the mechanism used to populate our data warehouse with change data. Previously we used SQL Server change data capture, which was extremely simple, but of course we don't have database access in 365. >:(
So, I am attempting to send a `RetrieveEntityChangesRequest` via a `CrmServiceClient` instead. The request appears to work successfully, and I do get a response, but if I iterate over the attributes in the returned entities, they do not contain all of the fields I specified in the request.Columns. If I use Query.ColumnSet(true) (to return all columns), I still don't get all of the fields I can see in the web UI (that is to say, in settings > customizations > customize the system > entities > fields).
I considered the possibility that perhaps the RetrieveEntityChangesRequest only returns fields where a value has in fact changed, but this can't be the explanation, since I am not populating the request DataVersion property in my test code, which I believe should return "everything".
What am I missing?
Here is my test code.
CrmServiceClient client = new CrmServiceClient
(
new Uri(@"https://myorghere.crm6.dynamics.com"),
@"redacted",
@"redacted",
false,
@"..\"
);
RetrieveEntityChangesRequest req = new RetrieveEntityChangesRequest();
req.EntityName = "account";
req.Columns = new Microsoft.Xrm.Sdk.Query.ColumnSet(true); // get all columns!
req.PageInfo = new Microsoft.Xrm.Sdk.Query.PagingInfo() { Count = 1, PageNumber = 1};
var resp = (RetrieveEntityChangesResponse)client.Execute(req);
foreach (var item in resp.EntityChanges.Changes)
{
if (item.Type == ChangeType.NewOrUpdated)
{
var e = (item as NewOrUpdatedItem).NewOrUpdatedEntity;
// our account entity has an "accountNumber" attribute, but it is not returned (and many other attributes are not returned either)
foreach (var a in e.Attributes.OrderBy(a => a.Key))
{
Console.WriteLine(a.Key);
}
}
}
Console.ReadKey();