The `Prefer: odata.track-changes` header is pretty useful to synchronize entire entities.
However this seems to work only if the user has a Global level prvRead<Entity> priviledge.
Otherwise it's returning this kind of error:
GET /api/data/v9.2/accounts?$select=name
Prefer: odata.track-changes
SecLib::CheckPrivilege failed. User: xxxxxxxxxxxxxxxxxxxxxxxxxxx, PrivilegeName: prvReadAccount, PrivilegeId: xxxxxxxxxxxxxxxxxxxxxxxxxxx, Required Depth: Global, BusinessUnitId: xxxxxxxxxxxxxxxxxxxxxxxxxxx, MetadataCache Privileges Count: 7356, User Privileges Count: 586
I'm guessing this is also why query options are not allowed in a "track-changes" request.
In another hand this seems to be based on the native SQLServer Change Tracking feature, which seems to me that could allow filtering.
Couldn't we "simply" join the result of CHANGETABLE() internally ?
So my final question is: How can I track the changes of data accessible by a user for a specific entity for which he does not have the global level privilege ?
Maybe I should not use track-changes
I'll try to do my own synchro system so.
Thanks again
For my experience I usually stay far away from the offline mobile feature. I don't know if it's possible to use the engine for a custom integration (maybe not all the API are available) but also in that case I would not use it.
Another idea would be to rely on the mobile offline feature but it seems reserved for PowerApps & FieldService, isn't it ?
Can we use that through FetchXml ?
Indeed inactive "soft delete" is an idea too, I'll think about it.
However I'd just like to make sure I can't do this SQL equivalent (inspired from CHANGETABLE doc) through FetchXml:
SELECT c.accountid , a.name , c.SYS_CHANGE_VERSION, c.SYS_CHANGE_OPERATION, , c.SYS_CHANGE_COLUMNS, c.SYS_CHANGE_CONTEXT FROM CHANGETABLE (CHANGES Accounts, @last_sync_version) AS c JOIN DynamicsSecurity AS d (c.accountid = d.accountid) LEFT JOIN Accounts AS a ON (a.accountid = c.accountid) WHERE d.user = @user ;
I'm abstracting the DynamicsSecurity here because I don't know how it's implemented, but it gives the idea.
@user & @last_sync_version are contextual.
In Dynamics you don't have the concept of soft-delete (so when a record is deleted is removed completely) but they have the active and inactive status (statecode field). You may "delete" the records putting them as Inactive.
However these are logic on the synchronization, you can decide how it operates as the change tracking data is not suitable for your needs
Thank you for your quick answer.
Here I'm talking about keeping track of changes for a certain amount of data.
I though about etag but there is one by object so I can hardly track changes on a big volume (without comparing each object's etag one by one), can I ?
`modifiedon` would be interesting but how to get the deleted objects since the latest sync ?
The change tracking feature seemed really close to what I was searching for, but it seems very limited and technically it would not need much to be able to get rid of this limitation.
I was not aware of that limitation but the error is pretty clear stating Global depth is required.
Regarding the SQL Server feature, keep in mind that Dataverse is still a layer built on top of SQL Server, this means that functions need to be implemented and more important Dataverse is now not only used with a SQL Server backend but also to other data sources (I am referring to Virtual Tables).
Track changes of data? if we talk about Web API there is the @odata.etag property that you can use, or you move to the more generic "modifiedon" field that gives you the last timestamp the record was modified.
hope it helps
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,151 Super User 2024 Season 2
Martin Dráb 229,963 Most Valuable Professional
nmaenpaa 101,156