Activity Dynamics CRM 2015 中的记录通过 FetchXML 查询在子网格中返回 - 主题超链接打开新 Activity

Activity records in Dynamics CRM 2015 returned in subgrid by FetchXML query - Subject hyperlink opens new Activity

我正在尝试在 Dynamics CRM 2015 中的联系人实体的表单上创建子网格,其中 return 包含所有电子邮件、任务、约会和 Phone 呼叫活动,其中 Activity 是关于已为其加载表格的联系人,或者该联系人是 Activity 中的参与者(即在电子邮件的发件人或 To/CC/BCC 字段中,或在参加者列表中一个约会)。

我在我的联系表中添加了一个新的子网格(现在称为 "NewActivities"),它使用我创建的特定 Activity 视图(并且设计的标准将 "never" return any results - DateCreated >= 01/01/2050) 然后创建了一个 javascript 函数,我将其作为 Web 资源包含在我的解决方案中,并在表单的 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();

}

希望以上是有道理的,我正在 returning 匹配 Activity 视图的属性,该视图在我设置的子网格中使用,然后过滤 Activity 我想要的类型,Activity Party 是页面上的联系人,对于所有参与类型(我想这可能是不必要的,但我的 FetchXML 是从高级查找查询构建的,所以它明确包括这些值,因为我选择了所有这些值)。

这似乎工作正常,因为当页面加载时,我在我的子网格中看到了正确的活动列表,但是如果我单击列表中任何活动的主题值,我将被带到 "New" Activity 的表单,而不是链接到列出的 Activity。因此,例如,如果我的子网格列表 returned 中有一封电子邮件,当我单击子网格中该 Activity 的主题列中的值时,它会加载新电子邮件表单而不是采用如我所料,我发送到那个特定的电子邮件 Activity 记录。

谁能告诉我为什么会这样,我该如何解决?

(I do also have an additional problem, whereby sometimes when navigating to this Contact Form, the subgrid does not always refresh - even though my javascript is definitely running - and so the subgrid shows no Activity records. If I refresh the subgrid manually after page load, the results are shown - I don't understand why this is happening either. It seems to be when navigating away from the Contact Form and then using the Back in my browser to return, but I have also had it happen on a page refresh. Sorry if I'm not meant to include two questions in the same post, I can obviously post this question separately if I need to, but thought it worth mentioning as it relates to the exact same functionality I'm trying to implement.)

我自己不尝试。可能只是完全忽略了这一点。但是,您的提取中没有 'Id' 属性。如果它在插件端,就不会有记录 ID在检索到的记录中..尝试添加 activitypointerid(或者它是那个的 activityid?)