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!");
                }
            }
        }
    }
  • 相关阅读:
    jquery新知识
    jquery回顾
    Filter和Listener
    jsp,jstl,el
    cookie和session
    servlet和HTTP原理
    xml基本知识
    linux 相关操作
    linux mysql 相关操作、问题
    linux 文件结构
  • 原文地址:https://www.cnblogs.com/luoyong0201/p/Dynamics_365_Delete_Plugin_Image.html
Copyright © 2011-2022 走看看