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基础(字典)

    #实现同样的功能,代码越少越好#非空即真,非0即真#not 取反 a = []b = ' 'c = ()d = 0e = Noneif a: print('真的')else: print('假的') ...

  2. 最近在研究syslog日志,就说一下syslog格式吧

    syslog格式:<PRI>HEADER MESSAGE syslog的消息长度:不超过1024.syslog格式举例:<15>Jul 10 12:00:00 192.168. ...

  3. 移动端调试神器 whistle

    移动端h5页面嵌入的方式多种多样,普通的chrome真机调试功能有时就不能满足要求了. whistle通过设置wifi服务器代理的方式,可以抓包调试所有移动端请求的页面. whistle的github ...

  4. like 内容转义

    如题,当SQL语句中使用Like查询,且期望匹配的结果中含有"\"的,应当把"\"替换为"\\\\". 比如数据库中text字段有以下三行: ...

  5. java实现截图功能

    package Jietu; import java.awt.Dimension; import java.awt.Rectangle; import java.awt.Robot; import j ...

  6. windows.h详解

    参考 http://blog.csdn.net/fengningning/article/details/2306650?locationNum=1&fps=1 windows.h解构 刚开头 ...

  7. pycharm介绍

      PyCharm是一种Python IDE(集成开发软件),带有一整套可以帮助用户在使用Python语言开发时提高其效率的工具. 1.1 PyCharm主界面 PyCharm包含4个主要区分,分别为 ...

  8. [转]CentOS7利用systemctl添加自定义系统服务

    原文:https://www.cnblogs.com/saneri/p/7778756.html CentOS7自定义系统服务 CentOS7的服务systemctl脚本存放在:/usr/lib/sy ...

  9. 2018上C语言程序设计(高级)作业- 第3次作业成绩

    作业地址 https://edu.cnblogs.com/campus/hljkj/CS2017-01/homework/1779 评分准则 第一次作业各项成绩包括三项: 完成PTA所有题目:13分 ...

  10. MySQL中MyISAM与InnoDB的主要区别对比

    特征 MyISAM InnoDB 聚集索引 否 是 压缩数据 是(仅当使用压缩行格式时才支持压缩MyISAM表.使用压缩行格式和MyISAM的表是只读的.) 是 数据缓存 否 是 加密数据 是(通过加 ...