Hi,
You could use http://xrmsvctoolkit.codeplex.com and a aggregate fetchxml query. Something like:
function fetchOperationCountSync()
{
var count;
var fetchXml =
"<fetch distinct='true' mapping='logical' aggregate='true'>" +
" <entity name='contact'> " +
" <attribute name='contactid' alias='contact_count' aggregate='countcolumn' /> " +
" <link-entity name='incident' from='customerid' to='contactid' alias='aa'>" +
" <filter type='and'>" +
" <condition attribute='incidentid' operator='eq' uiname='test' uitype='incident' value='" + Xrm.Page.data.entity.getId() + "' />" +
" </filter>" +
" </link-entity>" +
" </entity> " +
"</fetch>";
XrmSvcToolkit.fetch({
fetchXml: fetchXml,
async: false,
successCallback: function (result)
{
count = result.entities[0]["contact_count"];
},
errorCallback: function (error)
{
throw error;
}
});
return count;
}
hth,
Scott
Scott Durow
Blog www.develop1.net
Follow Me
Rockstar365
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"