zoukankan      html  css  js  c++  java
  • 创建一个dynamics 365 CRM online plugin (五)

    Snapshots of the primary entity's attributes from database before(pre) and after (post) the core platform operation.

    怎么理解这句话呢

    简单的我们可以理解PreOperation与PostOperation的 entity中数据的镜像.

    使用Pre-Entity镜像的一些案例:

    1. 如果你需要对original data在modification之前做使用.

    2. 如果你需要form的original data没有被modified修改之前做读取.

    PS: local name 为field的label name/entity name. Schema name 为数据库中field的名字  

    这次我们将修改leader 中的filedbusiness telephone number(logical name 为telephone1)

    我们将plugin中try模块里面的代码用以下代码覆盖掉

    我们可以看到,我们获取了modifiedBusinessPhone 为update之后的值.

    我们又使用了preImage这个value 从PreEntityImages镜像中获取original value 为originalBusinessPhone

    // Plug-in business logic goes here.  
    
    
                        //Pre and post entity images
                        // Snapshots of the primary entity's attributes from database before (pre) and after (post) the core platfomr operation.
    
                        // This is modified business phone number
                        var modifiedBusinessPhone = entity.Attributes["telephone1"].ToString();
    
                        // Retrieve preEntity Images
                        var preImage = (Entity)context.PreEntityImages["PreImage"];
    
                        // Normally we don't retrieve post entity images with following reason
                        // 1. After the postOperation, we are on the current situation modifed data
                        // 2. When retrieve the postEntityImages, due to it is not created, the entity will be null.
                        // Entity postImage = (Entity)context.PostEntityImages["PostImage"];
    
                        // Retrieve original business phone number
                        var originalBusinessPhone = preImage.Attributes["telephone1"].ToString();
    
                        // Display the information in the error log
                        throw new InvalidPluginExecutionException("Phone number is changed from" + originalBusinessPhone + " to " + modifiedBusinessPhone);

    我们build代码之后打开我们的plugin registration tool.

    点开我们的MyCRM Assembly, 点开class PreEntityImageDemo(我创建的新的class名称).

    在update我们的MyCRM assembly之后,我们点击建立新的Step

    创建dynamics CRM plugin

    创建Step之后, 我们需要右键Step建立image

    创建dynamics CRM plugin

    PS:因为我们不需要全局的fields都做触发,所以在register step的时候切记Filtering Attributes只勾选telephone1, 创建image镜像的时候只在Parameters中指勾选telephone1.

    我们打开我们的CRM的lead

    创建dynamics CRM plugin

    点击保存之后,可以发现我们的business Phone 有在error log中改动

    创建dynamics CRM plugin

  • 相关阅读:
    Codeforces 449D:Jzzhu and Numbers
    51nod 1040:最大公约数之和
    51nod 1179:最大的最大公约数
    51nod 1406:与查询
    51nod 1354:选数字
    51nod 1616:最小集合
    Codeforces:Colored Balls
    素性测试
    秒转换成年月日时分秒 和复制文本到剪贴板
    vue项目中获取cdn域名插件
  • 原文地址:https://www.cnblogs.com/TheMiao/p/10747699.html
Copyright © 2011-2022 走看看