How Do We Register A Plugin In Child Pipeline In D365. Give Examples
Stage of Execution:
Pre-Stage : (synchronous) chosen before the write to the database.
The main reasons to use a Pre-Stage of Execution are synchronous in nature:
- Modify data before it is written to the database.
- Arrest the action being taken
- Server Side Validity checking
Post-Stage : (synchronous or asynchronous)
Use the Post-Phase of Execution whenever yous don't need to utilise Pre-Stage.
If you lot don't want the user to wait for the procedure to cease and in that location is no race condition use asynchronous.
Information Images:
Pre-Image: Become the image of the record every bit is stored in the SQL database before the CRM Platform action has been performed
Post-Image: Returns the image of the record afterwards the CRM Platform action has been performed
Pipeline:
Parent Pipeline: This is the pipeline that is the most mutual and there are no restrictions imposed in a parent pipeline.
Child Pipeline: This is the pipeline that causes the most confusion and there are limitations that vary with Phase and Execution Mode.
Sometimes a child pipeline is required to trap the event you need, and sometimes you need to trap both the parent and child pipeline for the aforementioned entity, message and stage
Have a look on post-obit example for getting divergence betwixt Parent and Kid Pipeline:
We tin can create "Quote" in following ways:
1. Sales->Quotes->New
2. Sales->Opportunity->(Open Opportunity)->Quotes->New Quote
Let u.s. take first scenario Sales->Quotes->New
using Arrangement;
using Organisation.Collections.Generic;
using System.Text;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Query;
using Microsoft.Crm.SdkTypeProxy;
using Microsoft.Crm.SdkTypeProxy.Metadata;
using Microsoft.Crm.Sdk.Metadata;
using System.Spider web.Services;
using Microsoft.Win32;
namespace TestQuotePlugin
{
public class QuotePlugin : IPlugin
{
public void Execute(IPluginExecutionContext context)
{
ICrmService crmService = (ICrmService)context.CreateCrmService(truthful);
IMetadataService metaData = context.CreateMetadataService(true);
lead ld = new lead();
ld.subject = "Exam Subject";
ld.firstname = "Test FirstName";
ld.lastname = "Test LastName";
ld.companyname = "Exam Company";
crmService.Create(ld);
}
}
}
Register higher up plug-in equally post-obit:
Create new Quote from Sales -> Quotes -> New, then it will piece of work and create a new Lead.
But when you create a Quote from
Sales->Opportunity->(Open Opportunity)->Quotes->New Quote and so it will not work.
So you take to register a new child pipeline plug-in every bit following:
using System; using Organisation.Collections.Generic; using System.Text; using Microsoft.Crm.Sdk; using Microsoft.Crm.Sdk.Query; using Microsoft.Crm.SdkTypeProxy; using Microsoft.Crm.SdkTypeProxy.Metadata; using Microsoft.Crm.Sdk.Metadata; using System.Spider web.Services; using Microsoft.Win32; namespace TestQuotePlugin { public class QuotePlugin : IPlugin { public void Execute(IPluginExecutionContext context) { CrmService crmService = CreateCrmService(context); lead ld = new lead(); ld.discipline = "Test Field of study"; ld.firstname = "Test FirstName"; ld.lastname = "Exam LastName"; ld.companyname = "Test Company"; crmService.Create(ld); } private static CrmService CreateCrmService(IPluginExecutionContext context) { CrmAuthenticationToken token = new CrmAuthenticationToken(); token.AuthenticationType = AuthenticationType.AD; token.OrganizationName = context.OrganizationName; CrmService crmService = new CrmService(); crmService.UseDefaultCredentials = true; crmService.Url = (string)(Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\MSCRM").GetValue("ServerUrl")) + "/2007/crmservice.asmx"; crmService.CrmAuthenticationTokenValue = token; return crmService; } } } So now when y'all create a Quote from Sales->Opportunity->(Open Opportunity)->Quotes->New Quote then information technology volition work. Hard Coded Restrictions: A CrmService running Synchronously in a child pipeline is limited to the post-obit: · Create · Delete · Update · RetrieveExchangeRate However a child plugin running in Asynchronous Execution Mode is not express this fashion. Those 4 allowed deportment are difficult coded by MS whenever the plugin is executed inside a transaction, and it appears that all synchronous child pipeline events occur inside a transaction. However you lot can do a query in child pipeline if it is registered as asynchronous. In review: · Use ICrmService for all parent pipelines when at all possible. · Utilize CrmService for child pipelines in asynchronous execution mode. · There is very express functionality allowed with CrmService for any plugin registered in a synchronous child pipeline · Querying CRM data in a plug-in registered as a synchronous Pre Create in a kid process is currently unsupported. (i.east. direct SQL access)
How Do We Register A Plugin In Child Pipeline In D365. Give Examples,
Source: http://msdynamicscrm4all.blogspot.com/2011/09/difference-between-parent-and-child.html
Posted by: artisshesho.blogspot.com

0 Response to "How Do We Register A Plugin In Child Pipeline In D365. Give Examples"
Post a Comment