@ChrisPiasecki , Yes I asked about "inside model driven app".
In model driven app I can manage a form - set hide or read only for attributes and have access to values in the form, but what about other Dataverse data? another Entity (table)?
I have found a way with OData.
{
var uniqueNotificationId = "OutstandingTasks";
Xrm.Page.ui.clearFormNotification(uniqueNotificationId);
var contactId = Xrm.Page.data.entity.getId().replace(/[{}]/g,"");
var currentUserId = Xrm.Page.context.getUserId().replace(/[{}]/g,"");
var req = new XMLHttpRequest();
var requestUrl = Xrm.Page.context.getClientUrl() + "/api/data/v8.2/tasks?$filter=_regardingobjectid_value eq " + contactId + " and _ownerid_value eq " + currentUserId + " and statecode eq 0";
req.open("GET", requestUrl, true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Prefer", "odata.include-annotations=\"OData.Community.Display.V1.FormattedValue\"");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var results = JSON.parse(this.response);
if(results.value.length > 0){
Xrm.Page.ui.setFormNotification("You have outstanding tasks assigned to you.", "WARNING", uniqueNotificationId)
}
}
else {
//.. handle error
}
}
};
req.send();
}
But OData is an obsolete way. I'd like to use SQL query, is it possible?