CSHARP
/// <summary>
/// <list type="bullet">
/// <item>模块:售前(示例)</item>
/// <item>功能</item>
/// <list type="number">
/// <item>功能描述 xxxx xxxx xxxx</item>
/// <item>功能描述 xxxx xxxx xxxx</item>
/// </list>
/// <item>Primary Entity: Lead</item>
/// <item>Message: Update</item>
/// <item>Update Attributes: qualifyingopportunityid, statecode</item>
/// <item>State: PostOperation</item>
/// <item>Mode: Synchronous</item>
/// </list>
/// </summary>
点击展开查看更多

Message/State/Mode选项

示例

CSHARP
using Microsoft.Xrm.Sdk;
using System;

namespace Blog.D365.Plugins.Account
{
    /// <summary>
    /// <list type="bullet">
    /// <item>模块:售前(示例)</item>
    /// <item>功能</item>
    /// <list type="number">
    /// <item>功能描述 xxxx xxxx xxxx</item>
    /// <item>功能描述 xxxx xxxx xxxx</item>
    /// </list>
    /// <item>Primary Entity: Lead</item>
    /// <item>Message: Update</item>
    /// <item>Update Attributes: qualifyingopportunityid, statecode</item>
    /// <item>State: PostOperation</item>
    /// <item>Mode: Synchronous</item>
    /// </list>
    /// </summary>
    public class AccountPostUpdate : IPlugin
    {
        public void Execute(IServiceProvider serviceProvider)
        {
            ITracingService tracer = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            try
            {
                if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
                {
                    IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                    IOrganizationService service = factory.CreateOrganizationService(context.UserId);
                    IOrganizationService serviceAdmin = factory.CreateOrganizationService(null);                    
                    Entity currentEntity = (Entity)context.InputParameters["Target"];
                }
            }
            catch (Exception ex)
            {
                tracer.Trace($"AccountPostUpdate unexpected exception:\n{ex.Message}");
                throw;
            }
        }
    }
}
点击展开查看更多

效果

注释效果

版权声明

作者: Donghai Gong

链接: https://mgrowup.com/posts/d365/plugin-comments-temp/

许可证: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

评论

Current Language: zh-cn

开始搜索

输入关键词搜索文章内容

↑↓
ESC
⌘K 快捷键