Able to capture the count of the Dynamics insights using below code in browser console.
var data = {
WidgetRequest: '{"WidgetId":"MessageEmailOpenedByContactList",' +
'"Top":15,' +
'"SkipToken":"",' +
'"LanguageId":"1033",' +
'"OffsetFromUtcInMinutes":120,' +
'"Filter":' +
'{"DateFrom":"2020-11-17T18:20:34.711Z",' +
'"DateTo":"2020-12-29T18:20:34.711Z",' +
'"Properties":[' +
'{"Name":"MessageId",' +
//'"Value":"8fba7c3c-1b39-eb11-a813-000d3ab29b65"' +
//'"Value":"4aec99e2-d93e-eb11-a813-000d3ab29b65"' +
'"Value":"242473a8-c32d-eb11-a813-000d3ab29b65"' +
'}' +
']}' +
'}'
};
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/msdyncrm_ListWidgetData", true);
console.log("URL : " + Xrm.Page.context.getClientUrl() + "/api/data/v9.1/msdyncrm_ListWidgetData");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204 || this.status === 200) {
var results = JSON.parse(this.response);
console.log(typeof results );
var finalresult=results.WidgetData ;
console.log(typeof finalresult);
var jsonData = JSON.parse(finalresult);
console.log("Json Length : " + jsonData.data.length);
} else {
var error = JSON.parse(this.response).error;
Xrm.Utility.alertDialog("Error in Action: " + error.message);
}
}
};
req.send(JSON.stringify(data));
Now we want to create new dashboard with the values from the dynamics insights
What is the best approach for this
We are thinking to have custom fields on the Marketing Email Form and update them whenever there is an update on the dynamics insight
Is it possible to use either
1) Javascript ?
Or
2) Plugin ?
Also what should be the triggering points when we use any one of the above approaches.
If we go via JS route when should the Javascript trigger on which fields?
If we go via Plugin route what are the fields to be considered?
Or there is any other approach for this?
Kind Regards
Abhilash Reddy.