2

Mobile Express (ME) でのみ表示できるカスタム アクティビティ エンティティを作成しました。CRM Online のすべてのビューのクエリを調整して、カスタム エンティティと同じタイプのエンティティを除外することはできますが、それは少し面倒な作業です。

より高いレベルで、このカスタム エンティティをすべてのアクティビティビューから除外するように設定する別の方法はありますか?

4

1 に答える 1

0

あなたの質問を正しく理解している場合、カスタムを除外してビューactivityに他activityのすべての を含める唯一の方法は、手動で、またはエンティティをループしてActivityビューの基になる を変更することです(以下を参照)。を参照しません。カスタムが特定のビューに表示されないようにするためのフラグはありません。これを反映するには、すべてのビューを変更する必要があります(もちろん、カスタムがまったくない場合を除きます)。fetchXmlSavedQueryactivityactivityactivityentityactivity

//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-01-27T19:48:44.837 に答える