zoukankan      html  css  js  c++  java
  • Dynamics 365 CE在Pre Delete插件中应用Image

    微软动态CRM专家罗勇 ,回复327或者20190428可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!

    在插件中限制记录的删除是常见的场景,比如根据statuscode的状态来限制删除。

    这时候在实体的Delete消息的Pre Operation阶段注册一个插件,并注册一个Image,我这里类似如下:

     

    然后我这里使用插件代码类似如下:

    using Microsoft.Xrm.Sdk;
    using System;
    
    namespace Plugins
    {
        public class PreMyEntityDelete : IPlugin
        {
            public void Execute(IServiceProvider serviceProvider)
            {
                ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
                if(context.PreEntityImages.Contains("PreImg"))
                {
                    var statuscodeField = context.PreEntityImages["PreImg"].GetAttributeValue<OptionSetValue>("statuscode");
                    if(statuscodeField.Value != 1 && statuscodeField.Value != 2)
                    {
                        throw new InvalidPluginExecutionException("Only draft or inactive request can be deleted!");
                    }
                }
                else
                {
                    throw new InvalidPluginExecutionException("Pre delete image - PreImg does not exist!");
                }
            }
        }
    }
  • 相关阅读:
    windbg 内核模式调试用户进程
    深发展银行编码器(解剖)
    SIM300常用命令
    tdi驱动 for vista or later
    vm命令行控制 (vmrun)
    WMI事件监控
    Visual C++ 中 #pragma 指示符的使用
    IOCP开发的几个概念
    移动web.config文件时造成的错误,
    提高网站速度|页面优化
  • 原文地址:https://www.cnblogs.com/luoyong0201/p/Dynamics_365_Delete_Plugin_Image.html
Copyright © 2011-2022 走看看