【问题标题】:Choose value for Regarding field in Microsoft Dynamics CRM 2011 Mobile Express为 Microsoft Dynamics CRM 2011 Mobile Express 中的相关字段选择值
【发布时间】:2012-01-27 09:54:00
【问题描述】:

我创建了一个只能在 Mobile Express (ME) 中查看的自定义活动实体。我可以调整 CRM Online 中所有视图的查询,以排除类型等于我的自定义实体的实体,但这有点乏味。

是否有另一种方法可以在更高级别上设置从所有 Activity 视图中排除此自定义实体?

【问题讨论】:

    标签: dynamics-crm-2011 dynamics-crm-online


    【解决方案1】:

    如果我正确理解您的问题,排除自定义 activity 并将所有其他 activitys 包含在您的 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);
        }
    }
    

    您需要在此之后发布才能看到您所做的更改。

    【讨论】:

      猜你喜欢
      • 2012-12-21
      • 1970-01-01
      • 1970-01-01
      • 2018-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-25
      相关资源
      最近更新 更多