다음을 통해 공유


플러그인을 사용하여 케이스가 아닌 레코드 회람

IPlugin 인터페이스를 사용하여 프로그래밍 방식으로 이메일 메시지와 같은 대/소문자가 아닌 레코드에 대한 라우팅을 트리거할 수 있습니다.

Visual Studio의 콘솔 앱(.NET 프레임워크)에서 다음 샘플 코드를 사용할 수 있습니다. 이 코드는 다음 두 가지 조건을 확인하고 충족되면 msdyn_ApplyRoutingRuleEntityRecord 작업을 트리거합니다.

  • 웹 서비스 메시지가 레코드를 만드는 것인지 여부
  • 레코드가 전자 메일 메시지인지 여부입니다.
public class SamplePlugin : IPlugin 
{ 
    public void Execute(IServiceProvider serviceProvider) 
    { 
          // Obtain the tracing service 
        ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService)); 
        // Obtain the execution context from the service provider 
        IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); 
            // Check if create message 
            if (context.MessageName.ToLower().Equals("create")) 
            { 
                // The InputParameters collection contains all the data passed in the message request 
                if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) 
                { 
                    // Obtain the target entity from the input parameters 
                    Entity entity = (Entity)context.InputParameters["Target"]; 
                    // Target is an email 
                    if (entity.LogicalName.ToLower().Equals("email")) 
                    { 
                        try 
                        {  
                            // Obtain the organization service reference that you'll need for web service calls 
                            IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); 
                            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); 
                            // Execute msdyn_ApplyRoutingRuleEntityRecord request 
                            OrganizationRequest request = new OrganizationRequest("msdyn_ApplyRoutingRuleEntityRecord"); 
                            request["Target"] = new EntityReference("email", entity.Id); 
                            service.Execute(request); 
                        } 
                        catch (Exception ex) 
                        { 
                            tracingService.Trace("SamplePlugin: {0}", ex.ToString()); 
                            throw; 
                        } 
                    } 
                } 
            } 
        } 
    } 
}

회람 개요
레코드에 대한 회람 설정
레코드를 수동으로 회람
흐름을 사용하여 레코드를 자동으로 라우팅