I have been able to pull down an audit table from Dynamics 365 and load it into Power BI by selecting Get Data, choosing the odata option and using url/api/data/v9.1/audits
. I see the column RetrieveAuditDetails
, but I don't understand why all the values say Function . Is there a way to extend this to show the old value/new value in the same way you can change, for example, UserIDs to be extended to the full name?
When it comes to audit data, OData/Web API REST endpoint is not so friendly in PowerBI due to the reason that the audit data is stored as delimited values in database. Refer my answer in this SO thread .
If it's a javascript or .net application you can do iterative call using RetrieveAuditDetails
function to fetch full details after getting full list using https://crmdev.crm.dynamics.com/api/data/v9.1/audits
. This is why you are seeing as Function in there.
For example:
var parameters = {};
var entity = {};
entity.id = "5701259e-59b8-e911-bcd0-00155d0d4a79";
entity.entityType = "audit";
parameters.entity = entity;
var retrieveAuditDetailsRequest = {
entity: parameters.entity,
getMetadata: function() {
return {
boundParameter: "entity",
parameterTypes: {
"entity": {
"typeName": "mscrm.audit",
"structuralProperty": 5
}
},
operationType: 1,
operationName: "RetrieveAuditDetails"
};
}
};
Xrm.WebApi.online.execute(retrieveAuditDetailsRequest).then(
function success(result) {
if (result.ok) {
var results = JSON.parse(result.responseText);
}
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);
Update : On further analysis - there is no big difference between the output schema from the above RetrieveAuditDetails
query targeting single auditid
or the below filtered audits
query targeting single recordid
.
https://crmdev.crm.dynamics.com/api/data/v9.1/audits?$filter=_objectid_value eq 449d2fd8-58b8-e911-a839-000d3a315cfc
The fact is either web api or fetchxml, the resultset cannot fetch the important column changedata
which contains the changed field values - due to the restriction: Retrieve can only return columns that are valid for read. Column : changedata. Entity : audit
Retrieve can only return columns that are valid for read. Column : changedata. Entity : audit
I get this in FetchXML builder:
There is another approach but not PowerBI compatible anyway, using RetrieveRecordChangeHistory
to target the recordid
to get all the audit collections with old & new values. Example below:
https://crmdev.crm.dynamics.com/api/data/v9.0/RetrieveRecordChangeHistory(Target=@Target)?@Target={%22accountid%22:%22449d2fd8-58b8-e911-a839-000d3a315cfc%22,%22@odata.type%22:%22Microsoft.Dynamics.CRM.account%22}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.