一、如何指定 Partylist 类型字段能 lookup 的实体(以 Appointment 中某个字段为例子):
代码如下:
var control = Xrm.Page.getControl("requiredattendees"); control.getAttribute().setLookupTypes(["systemuser", "contact"]);
执行前:
执行后:
二、使用 JavaScript 对 sub-grid 进行过滤,具体过程如下:
1.首先打开 CRM 系统的 Advanced Find:
2.选择 Sub grid 对应的 Entity(以 Appointment 为例子),并添加所需要的筛选条件,点击下载 Fetch XML:
3.下载后得到的文本内容如下(有所省略,只是一个sample):
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"> <entity name="appointment"> <attribute name="..." /> <attribute name="..." /> ... <attribute name="..." /> <order attribute="..." descending="true" /> <filter type="and"> <condition attribute="actualend" operator="on-or-after" value="2019-04-16" /> </filter> </entity> </fetch>
4.在 JavaScript 中调用 XML 对 Sub grid 进行过滤:
var sSubGridName = "..." //Sub grid的名字 var caseXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" + "<entity name='appointment'>" + "<attribute name='...' />" + "..." + "<attribute name='...' />" + "<order attribute='...' descending='true' />" + "<filter type='and'>" + "<condition attribute='actualend' operator='on-or-after' value='2019-04-16' />" + "</filter>" + "</entity>" + "</fetch>"; var SubGridDetails = window.parent.document.getElementById(sSubGridName); if (SubGridDetails != null) { if (SubGridDetails.control != null) { SubGridDetails.control.SetParameter("fetchXml", caseXml); //set the fetch xml to the sub grid SubGridDetails.control.refresh(); //refresh the sub grid using the new fetch xml } }