我创建了一个只能在 Mobile Express (ME) 中查看的自定义活动实体。我可以调整 CRM Online 中所有视图的查询,以排除类型等于我的自定义实体的实体,但这有点乏味。
是否有另一种方法可以在更高级别上设置从所有活动视图中排除此自定义实体?
我创建了一个只能在 Mobile Express (ME) 中查看的自定义活动实体。我可以调整 CRM Online 中所有视图的查询,以排除类型等于我的自定义实体的实体,但这有点乏味。
是否有另一种方法可以在更高级别上设置从所有活动视图中排除此自定义实体?
如果我正确理解您的问题,排除 customactivity
并将所有其他activity
s 包含在您的视图中的唯一方法是手动或通过遍历实体(见下文)Activity
来更改视图的底层,以确保视图不引用. 您无法设置任何标志来阻止您的自定义显示在任何特定视图中;您需要更改所有视图以反映这一点(当然,除非您的自定义根本不是)。fetchXml
SavedQuery
activity
activity
activity
entity
activity
//using System.Xml.Linq;
//your list of activity entities excluding the special custom activity
string activityList = "<condition attribute=\"activitytypecode\" operator=\"in\"><value>4401</value><value>4204</value><value>10058</value></condition>";
XElement newFilter = XElement.Parse(activityList);
var sq = from q in xsc.SavedQuerySet
where q.ReturnedTypeCode == ActivityPointer.EntityLogicalName
select new
{
fetchXml = q.FetchXml
, queryId = q.SavedQueryId
, queryName = q.Name
};
foreach (var q in sq)
{
//do your xml parsing
XElement xml = XElement.Parse(q.fetchXml);
if (!xml.Elements("entity")
.Elements("filter").Where(x => x.Attributes("type").Single().Value == "and").Any())
{
xml.Elements("entity").Single().Add(XElement.Parse("<filter type=\"and\"></filter>"));
}
//some level of validation
if (!xml.Elements("entity")
.Elements("filter")
.Where(x => x.Attributes("type").Single().Value == "and")
.Single().Elements("condition")
.Where(x => x.Attributes("attribute")
.Single().Value == "activitytypecode")
.Where(x => x.Attributes("operator")
.Single().Value == "in").Any())
{
xml.Elements("entity")
.Elements("filter")
.Where(x => x.Attributes("type")
.Single().Value == "and")
.Single().Add(newFilter);
SavedQuery query = new SavedQuery();
query.SavedQueryId = q.queryId;
query.FetchXml = xml.ToString();
service.Update(query);
}
}
您需要在此之后发布才能看到您的更改。