【问题标题】:Dynamics CRM how to bring the current Id of a entity recordDynamics CRM如何带上一个实体记录的当前Id
【发布时间】:2016-11-01 07:20:37
【问题描述】:

我是社区的新手,我正在为一个表单插件而苦恼,我需要在其中获取该表单的所有值,为了实现这一点,我创建了一个 preOperation 更新插件。只有当我修改该表单内的字段时,我的插件才能完美运行。但是,普通用户(我是管理员)不能修改表单的任何值。 我读到我可以使用该方法

service.Retrieve(string entityName, Guid id, ColumnSet columnSet);

我的问题是如何获取当前记录的 Guid id? 对不起,如果这很明显,但我是 Dynamics CRM 的新手,我很感激你能给我的任何帮助。

【问题讨论】:

    标签: c# dynamics-crm-2011 dynamics-crm dynamic-programming


    【解决方案1】:

    如果您不想使用实体的前/后图像,您可以检索您在问题中提到的记录。如果您的插件在更新消息上注册,则获取当前记录的 ID 很容易。

    Entity entity = (Entity)context.InputParameters["Target"];
    Guid recordID = entity.Id;
    

    也看看这个。

    https://community.dynamics.com/crm/b/crminogic/archive/2010/07/26/pre-image-38-post-image-explained-33

    【讨论】:

      【解决方案2】:

      由于您的插件是在预操作级别注册的,因此该记录还没有写入数据库。

      您必须使用已注册的实体前图像来访问属性(表单值)。

      var pluginExecutionContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
      var entity = pluginExecutionContext.PreEntityImages["ImageName"]; //the name that you have registered your image with
      //iterate through all the attributes 
      foreach (var attribute in entity.Attributes)
      {
        //access the attribute values
        var attributeValue = attribute.Value;  
      }
      

      【讨论】:

        猜你喜欢
        • 2019-04-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-17
        • 1970-01-01
        • 2014-12-01
        相关资源
        最近更新 更多