• Dynamics CRM


    C# Plugin - 獲取 <From> 的值

          在這裏 Mark 一下 C# Plugin 中是如何對 PartyList 類型字段進行取值的,以 <From> 字段爲例,我們想取得 <From> 字段裏所有的 AccountId:

     1 List<Guid> list_account = new List<Guid>();
     2 EntityCollection from = entity.GetAttributeValue<EntityCollection>("from");
     3 if(from != null)
     4 {
     5     foreach(var _entity in from.Entities)
     6     {
     7         EntityReference item = _entity.GetAttributeValue<EntityReference>("partyid");
     8         if(item != null && item.LogicalName == Account.EntityLogicalName)
     9         {
    10             if (!list_account.Exists(a => a == item.Id))
    11             {
    12                 list_account.Add(item.Id);
    13             }
    14         }
    15     }
    16 }

          説明一下: party list 類型字段實際上是一個集合,它包括了多個 Entity 對象(Activity Party 類型),在Activity Party <Party Id> 字段中存放了 <From> 中所選擇的 record,<Activity Id> 存的是 Ativities record,比如新建一條 Email record,<From> = Account A; Account B,save record 后,假設該條 Email 的 Guid 是 guid A,那麽在 Activity Party 表中會多了幾條 Activity Id = guid A 的 record (ActivityPartyId 不同),其中就包裹了 PartyId = Account A Id 和 PartyId = Account B Id 的record,<Party Id> 是一個 Lookup 類型的字段,我們可以根據 logical name 來判斷它屬於哪個 entity。

          以上就是對 PartyList 類型字段進行取值的方法,另外需要注意的是,在 Delete Plugin 中,如果需要對 PartyList 字段進行取值,建議將 Delete Plugin 方法寫在 PreValidation(stage 10)中,後面會再更新一篇關於 PartyList 類型字段在 C# Plugin 和 JavaScript 中是如何賦值的。

  • 相关阅读:
    【bozj2287】【[POJ Challenge]消失之物】维护多值递推
    书籍
    图书管理系统-单表的增删改查
    Django之ORM
    app的创建和注册
    登陆示例
    django 静态文件配置
    安装django及配置
    Bootstrap
    导图
  • 原文地址:https://www.cnblogs.com/Sunny20181123/p/12007901.html
Copyright © 2020-2023  润新知