我正在尝试在Dynamics CRM 2015中的联系实体的表单上创建子网格,该表单返回所有电子邮件,任务,约会和电话呼叫活动,其中活动是关于已加载表单的联系人,或者联系人是活动的参与者(即在电子邮件的发件人或To / CC / BCC字段中,或在约会的与会者列表中)。
我已经在我的联系表单中添加了一个新的子网格(现在称为“NewActivities”),该表格使用我创建的特定活动视图(并且设计的标准将“永不”返回任何结果 - DateCreated> = 01/01/2050)然后创建了一个javascript函数,我已将其作为Web资源包含在我的解决方案中并且正在调用Form的OnLoad事件:
function DisplaySubGrid() {
var subgrid = document.getElementById("NewActivities");
if (subgrid == null) {
setTimeout('DisplaySubGrid()', 1000);
return;
}
var fetchXml =
"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>"
+ "<entity name='activitypointer'>"
+ "<attribute name='activitytypecode' />"
+ "<attribute name='subject' />"
+ "<attribute name='statecode' />"
+ "<attribute name='regardingobjectid' />"
+ "<attribute name='ownerid' />"
+ "<attribute name='scheduledend' />"
+ "<attribute name='createdby' />"
+ "<attribute name='createdon' />"
+ "<order attribute='scheduledend' descending='false' />"
+ "<order attribute='subject' descending='false' />"
+ "<filter type='and'>"
+ "<condition attribute='activitytypecode' operator='in'>"
+ "<value>4201</value>"
+ "<value>4202</value>"
+ "<value>4210</value>"
+ "<value>4212</value>"
+ "</condition>"
+ "</filter>"
+ "<link-entity name='activityparty' from='activityid' to='activityid' alias='ae'>"
+ "<filter type='and'>"
+ "<condition attribute='participationtypemask' operator='in'>"
+ "<value>4</value>"
+ "<value>3</value>"
+ "<value>11</value>"
+ "<value>6</value>"
+ "<value>7</value>"
+ "<value>9</value>"
+ "<value>8</value>"
+ "<value>5</value>"
+ "<value>10</value>"
+ "<value>1</value>"
+ "<value>2</value>"
+ "</condition>"
+ "<condition attribute='partyid' operator='eq' uiname='" + Xrm.Page.getAttribute("fullname").getValue() + "' uitype='contact' value='" + Xrm.Page.data.entity.getId() + "' />"
+ "</filter>"
+ "</link-entity>"
+ "</entity>"
+ "</fetch>"
subgrid.control.SetParameter("fetchXml", fetchXml);
subgrid.control.refresh();
}
希望上面有意义,我返回的属性与我设置的子网格中使用的活动视图的属性相匹配,然后过滤我想要的活动类型以及活动方的位置对于所有参与类型,请在页面上联系(我想这可能是不必要的,但我的FetchXML是从高级查找查询构建的,因此它明确包含了值,因为我选择了所有这些值。)
这似乎工作正常,因为我在页面加载时看到了子网格中正确的活动列表,但如果我点击列表中任何活动的主题值,我将被带到“新”该活动的表单,而不是链接到列出的活动。因此,例如,如果我的子网格列表中有一个电子邮件返回,当我在子网格中单击该活动的主题列中的值时,它会加载新电子邮件表单,而不是将我带到特定的电子邮件活动记录,因为我期待。
任何人都可以告知为什么会这样,以及我如何解决它?
(我还有一个额外的问题,有时甚至是 导航到此联系表单时,子网格并不总是刷新 - 即使我的javascript肯定在运行 - 所以subgrid 显示没有活动记录。如果我之后手动刷新子网格 页面加载,结果显示 - 我不明白为什么会这样 也发生了。似乎是在远离联系表格的情况下导航 然后在我的浏览器中使用Back返回,但我也有 它发生在页面刷新上。对不起,如果我不打算包括在内 在同一篇文章中的两个问题,我显然可以发布这个问题 如果我需要分开,但认为值得一提,因为它涉及 与我正在尝试实现的完全相同的功能。)
答案 0 :(得分:2)
没有自己尝试..可能只是完全忽略了这一点..但是,你的fetch中没有'Id'属性..如果它在插件端,在检索到的记录中将没有记录id ..尝试添加activitypointerid(或者它是那个活动的?)