创建一个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中改动

原文地址:https://www.cnblogs.com/TheMiao/p/10747699.html

时间: 2024-08-01 08:36:38

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

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

我们之前创建的plugin都是使用default的 run in User's Context. 理解就是使用正在登陆的security context用户信息 那有个问题,如果当前用户的security role没有相应的权限访问功能,我们就要安排一个新的用户 e.g. admin来记录信息而非当前用户. 让我们在registration tool更新TaskCreate class之后再CRM中打开新建Contacts. 我们可以打开activities发现follow up 里用户更改为在

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

Isolation Mode 也被称作为Plugin Trust CRM里面有两种plugin trust / isolation mode 1. Full Trust 只在OP系统中可使用,没有限制 plugin 挂掉之后会影响到CRM服务器运行. 可以访问服务器文件 2. Partial Trust or Sandbox 可在OP系统和online系统中使用 运行在特定的区域中,当plugin crash之后, CRM系统不会随之崩盘 Plugin 在secure layer底下运行, 并且

怎样创建一个dynamics 365 CRM online plugin (二)

Golden Rules 1. Platform only passes Entity attributes to Plugin that has change of data. 2. If the user does not enter any value into attribute, the attribute is not avaible in AttributeCollection of Entity. 3. Always check if attribute is present i

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

CRM 可以实现plugin之前的值传递. 我们可以使用SharedVariables 把值在plugin之间传递 实现plugins之间的传递非常简单,我们只需要用key value pair来配对传递. 读取的时候用key来获取相应key的value try { /* * SharedVariabls can share the variabls to different plugins * SharedVariabls will only work under same pipeline

创建一个dynamics 365 CRM online plugin (十二) - Asynchronous Plugins

这篇是plugin的终结. 通过之前的11期我们应该发现了plugin其实学习起来不难. async plugin 是把plugin的功能async run起来. e.g.  我们之前做过的preOperation的plugin会马上执行并且马上有数据显示在entity中. 但是async plugin会在async 形式下run, 使用场景是有很大的计算量或者处理量会导致CRM server进程被block 掉. 我们可以在plugin registeration tool中选择是否需要asy

创建一个dynamics 365 CRM online plugin (四) (Not finished)

开始之前,我们要确认一下 Plugin 的 pipeline. PreValidation -> PreOperation -> Server Side System Main Event-> PostOperation PreValidation 是在security check 之前, 通常会用来加载外部数据和用户不相关的内容.PreOperation 是在security check 之后, 通常会用来做一系列的功能.PostOperation 是在System Main Even

创建一个dynamics CRM workflow (五) - Deploy Custom Workflows

我们打开plugin registeration tool. 注册一个新的assembly. custom workflow 和 plugin注册的方法还有些不同. 这一步custom workflow就结束了. 因为custom workflow是通过business workflow来使用的 下一步,我们需要找到之前创建好的 processes 在process中, 让我们添加写好的workflow. 添加custom workflow之后, 让我们点击set properties. 然后给

Dynamics 365 CRM Connected Field Service 自动发送command

上期降到了怎样部署connected field service(CFS) 我们假设现在IoT 设备是温度监控器, 当温度触发我们之前预设的温度值, IoT会通过IoT Hub 发送IoT Alert到CFS中. 第一次触发, 系统会自动发送reboot的command. 为了有更好的用户体验, 我们需要自动发送command. 自动发送非常简单. 首先,我们需要创建一个workflow 我们的workflow需要在IoT Alert创建的时候触发. 这个workflow需要有以下两步: 1.

怎样Debug Dynamics 365 CRM Plugin

写了这么多期的随笔,很多人会问,怎么debug写好的plugin呢 首先我们需要准备以下内容 Visual Studio Plugin Registration Tool CRM Instance Error Log 首先,我们要打开Plugin Registration Tool 然后我们需要Install Profiler install成功之后, 我们下一步要讲plugin的step  start profiling 我们选择exception之后点击确定 成功之后的step会显示如下 现