创建一个dynamics 365 CRM online plugin (五) - Images in 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

创建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的更多相关文章
- 创建一个dynamics 365 CRM online plugin (九) - Context.Depth
让我们来看看官方文档是怎么讲的 https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide ...
- 创建一个dynamics 365 CRM online plugin (七) - plugin当中的Impersonation角色
我们之前创建的plugin都是使用default的 run in User's Context. 理解就是使用正在登陆的security context用户信息 那有个问题,如果当前用户的securi ...
- 创建一个dynamics 365 CRM online plugin (四) - PreValidation
开始之前,我们要确认一下 Plugin 的 pipeline. PreValidation -> PreOperation -> Server Side System Main Event ...
- 创建一个dynamics 365 CRM online plugin (三) - PostOperation
上两节我们创建了一个 PreOperation的plugin 今天我们创建一个PostOpeartion的plugin和之前的plugin连接起来 当创建contact之后,我们要添加一个task给新 ...
- 创建一个dynamics 365 CRM online plugin (一) - Hello World Plugin
源代码连接:https://github.com/TheMiao/Dynamics365CRM/blob/master/MyCRM/MyCRM/HelloWorld.cs 首先,我们需要创建一个.NE ...
- 创建一个dynamics 365 CRM online plugin (十) - Isolation mode or trust mode
Isolation Mode 也被称作为Plugin Trust CRM里面有两种plugin trust / isolation mode 1. Full Trust 只在OP系统中可使用,没有限制 ...
- 创建一个dynamics 365 CRM online plugin (八) - 使用Shared Variables 在plugins 之前传递data
CRM 可以实现plugin之前的值传递. 我们可以使用SharedVariables 把值在plugin之间传递 实现plugins之间的传递非常简单,我们只需要用key value pair来配对 ...
- 创建一个dynamics 365 CRM online plugin (六) - Delete plugin from CRM
我们之前都学习到怎么添加,debug还有update plugin. 今天带大家过一下怎么从CRM instance当中删除plugin. 首先让我们打开Settings -> Customiz ...
- 创建一个dynamics 365 CRM online plugin (二) - fields检查
Golden Rules 1. Platform only passes Entity attributes to Plugin that has change of data. 2. If the ...
随机推荐
- change the version of python on my centos
There are two versions of aconda: aconda and aconda3 in my home directorys. When comment the environ ...
- 判断浏览器大于等于ie9
方便自己查找 <script> (function (window) { var theUA = window.navigator.userAgent.toLowerCase(); if ...
- Oracle学习DaySix(PL/SQL续)
一.游标 在 PL/SQL 程序中,对于处理多行记录的事务经常使用游标来实现.游标是一个指向上下文的句柄( handle)或指针.通过游标,PL/SQL 可以控制上下文区和处理语句时上 下文区会发生些 ...
- IIC_slaver 仿真错误
integer 类型不能直接赋值. 改正之后的代码
- 一道笔试题来理顺Java中的值传递和引用传递
题目如下: private static void change(StringBuffer str11, StringBuffer str12) { str12 = str11; str11 = ...
- Vue小技巧-懒加载
Vue懒加载包括图片懒加载与路由懒加载 1.图片懒加载: 首先安装 vue-lazyload包 然后导入并加载事先下载好的加载图片 import VueLazyLoad from 'vue-lazyl ...
- 埃式筛法——求n以内素数
素数筛法的关键就在一个“筛”字.算法从小到大枚举所有数,对每一个素数,筛去它的所有倍数,剩下的就都是素数了. 例如:求1-15中的所有素数. 1. 2是素数(唯一需要事先确定的),因此筛去2的所有倍 ...
- Kafka如何彻底删除topic及数据
前言:删除kafka topic及其数据,严格来说并不是很难的操作.但是,往往给kafka 使用者带来诸多问题.项目组之前接触过多个开发者,发现都会偶然出现无法彻底删除kafka的情况.本文总结多个删 ...
- Zookeeper原理、安装、基本使用和API
ZooKeeper ZooKeeper是一种分布式协调服务, 解决应用程序的分布式带来的问题. 1 分布式应用 分布式应用可以在给定时间(同时)在网络中的多个系统上运行,通过协调它们以快速有效的 ...
- pagerank算法在数学模型中的运用(有向无环图中节点排序)
一.模型介绍 pagerank算法主要是根据网页中被链接数用来给网页进行重要性排名. 1.1模型解释 模型核心: a. 如果多个网页指向某个网页A,则网页A的排名较高. b. 如果排名高A的网页指向某 ...