2012-01-27 87 views
2

我創建了應該只能在Mobile Express(ME)中查看的自定義活動實體。我可以調整CRM Online中所有視圖的查詢,以排除與我的自定義實體類型相同的實體,但這是一項乏味的工作。爲Microsoft Dynamics CRM 2011移動快車中的字段選擇值

是否有另一種方法可以在更高級別上設置排除該自定義實體的全部內容活動 views?

回答

0

如果我理解正確的話你的問題,要排除自定義activity,包括您在Activity視圖的所有其他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); 
    } 
} 

您需要在此之後發佈以查看您的更改條。