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

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

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

我们打开我们的CRM的lead

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

创建一个dynamics 365 CRM online plugin (五) - Images in Plugin的更多相关文章

  1. 创建一个dynamics 365 CRM online plugin (九) - Context.Depth

    让我们来看看官方文档是怎么讲的 https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide ...

  2. 创建一个dynamics 365 CRM online plugin (七) - plugin当中的Impersonation角色

    我们之前创建的plugin都是使用default的 run in User's Context. 理解就是使用正在登陆的security context用户信息 那有个问题,如果当前用户的securi ...

  3. 创建一个dynamics 365 CRM online plugin (四) - PreValidation

    开始之前,我们要确认一下 Plugin 的 pipeline. PreValidation -> PreOperation -> Server Side System Main Event ...

  4. 创建一个dynamics 365 CRM online plugin (三) - PostOperation

    上两节我们创建了一个 PreOperation的plugin 今天我们创建一个PostOpeartion的plugin和之前的plugin连接起来 当创建contact之后,我们要添加一个task给新 ...

  5. 创建一个dynamics 365 CRM online plugin (一) - Hello World Plugin

    源代码连接:https://github.com/TheMiao/Dynamics365CRM/blob/master/MyCRM/MyCRM/HelloWorld.cs 首先,我们需要创建一个.NE ...

  6. 创建一个dynamics 365 CRM online plugin (十) - Isolation mode or trust mode

    Isolation Mode 也被称作为Plugin Trust CRM里面有两种plugin trust / isolation mode 1. Full Trust 只在OP系统中可使用,没有限制 ...

  7. 创建一个dynamics 365 CRM online plugin (八) - 使用Shared Variables 在plugins 之前传递data

    CRM 可以实现plugin之前的值传递. 我们可以使用SharedVariables 把值在plugin之间传递 实现plugins之间的传递非常简单,我们只需要用key value pair来配对 ...

  8. 创建一个dynamics 365 CRM online plugin (六) - Delete plugin from CRM

    我们之前都学习到怎么添加,debug还有update plugin. 今天带大家过一下怎么从CRM instance当中删除plugin. 首先让我们打开Settings -> Customiz ...

  9. 创建一个dynamics 365 CRM online plugin (二) - fields检查

    Golden Rules 1. Platform only passes Entity attributes to Plugin that has change of data. 2. If the ...

随机推荐

  1. python学习笔记:2.python基础

    4.27 01,pycharm 安装使用. 011,昨日内容回顾.     编译型:         将代码一次性全部编译成二进制,然后运行.         优点:执行效率高.         缺点 ...

  2. Java中的静态方法和实例方法的调用的理解(不同的类下的方法调用)

    public class MethodCall { public static void main(String[] args) { Test.sayStatic(); Test test = new ...

  3. 在IDEA中以TDD的方式对String类和Arrays类进行学习

    要求 测试相关方法的正常,错误和边界情况 String类 charAt split Arrays类 sort binarySearch 提交运行结果截图和码云代码链接,截图没有水印的需要单独找老师验收 ...

  4. 选择性重传ARQ基本原理

    发送发可以连续发送多个数据包,接收方对于无差错的数据包进行正常接收,对于有差错数据包进行丢弃并发送NAKn进行差错反馈,对于n号数据包之后正确到达的数据包进行缓存,直到收到重发的,正确的n号数据包,再 ...

  5. div css 图片和文字上下居中对齐

    想要图片和文字水平居中对齐很容易,可今天做这个树的时候,遇到了要将图片上下居中.这下就不知道怎么搞. 拿手册看也看不出所以然来,不同的浏览器对DIV的支持不一个,目前最好的浏览器是Firefox. 这 ...

  6. matlab批量读取一个文件夹里类似命名的mat文件

    参考网址: Matlab读取同一路径下多个txt或mat文件总结 matlab 批量读取数据文件.mat .dat 整理:matlab批量读入数据文件的方法 首先命名方式体现在只是名字里数字有变化,其 ...

  7. JSF的分析

    一.JSF的有关定义 JavaServer Faces (JSF) 是一种用于构建Java Web 应用程序的标准框架 它提供了一种以组件为中心来开发 Java Web 用户界面的方法,从而简化了开发 ...

  8. css设置文字多余部分显示省略号

    如果只显示一行,则可以使用以下方法: overflow: hidden; text-overflow:ellipsis; white-space: nowrap; 如果需要显示多行,在需要设置的元素s ...

  9. 封装qq分享静态库到cocopod

    封装qq分享静态库到cocopod  1,创建framework库,到腾讯开放平台(open.qq.com)申请项目appid 2,将iOS SDK中的TencentOpenAPI.framework ...

  10. 从零开始写自己的PHP框架系列教程[前言]

    我觉得程序员进步的理由:多看->多写->多总结 我自我介绍下,我不是程序员,但是我爱编程,作为业余程序员自己写框架让人感到兴奋的,目前有很多框架(js有jQuery.Express.soc ...