Dynamics crm 2011 通过FetchXML获取相关实体计数
我有以下用于返回相关实体总数的fetchXML代码。主实体名称为新建交易,相关实体名称为新建交易产品 下面的代码放在一个web资源javascript中,但是当调用此函数时,它永远不会得到成功或错误部分,它只是挂起Dynamics crm 2011 通过FetchXML获取相关实体计数,dynamics-crm-2011,Dynamics Crm 2011,我有以下用于返回相关实体总数的fetchXML代码。主实体名称为新建交易,相关实体名称为新建交易产品 下面的代码放在一个web资源javascript中,但是当调用此函数时,它永远不会得到成功或错误部分,它只是挂起 function countLineItems() { var ID = Xrm.Page.data.entity.getId(); var fetchXml = "<fetch version='1.0' output-format='xml-platform' ma
function countLineItems()
{
var ID = Xrm.Page.data.entity.getId();
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' aggregate='true'>";
fetchXml += "<entity name='new_transactionproduct'>";
fetchXml += "<attribute name='new_name' alias='recordcount' aggregate='countcolumn' />";
fetchXml += "<filter type='and'>";
fetchXml += "<condition attribute='new_transactionid' operator='eq' value='" + ID + "' />";
fetchXml += "</filter>";
fetchXml += "</entity>";
fetchXml += "</fetch>";
alert(fetchXml);
XrmSvcToolkit.fetch({
fetchXml: fetchXml,
async: false,
successCallback: function (result) {
var countValue = result.entities[0].recordcount;
alert(countValue);
//Xrm.Page.getAttribute(new_totalqty).setValue(countValue);
},
errorCallback: function (error) {
throw error;
}
});
}
函数countLineItems()
{
var ID=Xrm.Page.data.entity.getId();
var fetchXml=“”;
fetchXml+=“”;
fetchXml+=“”;
fetchXml+=“”;
fetchXml+=“”;
fetchXml+=“”;
fetchXml+=“”;
fetchXml+=“”;
警报(fetchXml);
XrmSvcToolkit.fetch({
fetchXml:fetchXml,
async:false,
successCallback:函数(结果){
var countValue=result.entities[0].recordcount;
警报(countValue);
//Xrm.Page.getAttribute(新的总数量).setValue(countValue);
},
errorCallback:函数(错误){
投掷误差;
}
});
}
XrmSvcToolkit需要作为web资源添加并在页面上引用。只是一个简短的旁注,您可以始终像下面这样设置fetchXML,以尽量减少附加到字符串的时间
string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' aggregate='true'>
<entity name='new_transactionproduct'>
<attribute name='new_name' alias='recordcount' aggregate='countcolumn' />
<filter type='and'>
<condition attribute='new_transactionid' operator='eq' value='" + ID + @"' />
</filter>
</entity>
</fetch>";
string fetchXml=@”
";
你说的“挂起”是什么意思?它是否在不执行任何回调的情况下通过countLineItems?还是它进入了一个无限循环?使用调试器时会得到什么?回调永远不会执行,XrmSvcToolkit.fetch()行是挂起的位置(无限循环)。我开始认为您不能从CRM内的web资源运行XrmSvcToolkit.fetch()。这是对的吗?我知道这个答案很久以前就发布了,但是OP写的是JavaScript。你的答案是C#