Properties to check for Plugin Execution Context
Dynamics CRM Plugin code is always executed in certain context. It very important to check few properties to make sure code is executing in correct context before processing. This helps avoid unexpected behavior.
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext) serviceProvider.GetService(typeof(IPluginExecutionContext));
MessageName
If you want plugin to execute for specific event like Create or update, check message name. It is also helpful when you want to execute different logic for different events in same plugin
if (context.MessageName == "Create")
{
//Do something else
}
Stage
Stage determines whether you want to execute your logic pre-operation or post-operation. In CRM there are 4 event pipeline stages which are available to register plug-ins. It is important if you are expecting to use ID for a record for newly created record, you will need to make sure your code is running in post-operation
if (context.Stage == 10)// Pre-validation
{
//Do something else
}
else if (context.Stage == 20)//Pre Stage
{
//Do something else
}
else if (context.Stage == 40) //Post Stage
{
//Do something else
}
PrimaryEntityName
PrimaryEntityName lets you check to make sure that your code is being invoked for the expected entity
If (Context. PrimaryEntityName!=”account”)
{
//Show message that not expected entity
}
InputParameters
The InputParameters property contains in the request message being processed. Plugin can access/modify this data in request. Target is the most common input parameter used in plugins. It is of type enitity. Example if a plugin is processing an account record in create event, you can access fields related to account record through target input parameter.
// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is EntityReference)
{
// Obtain the target entity from the input parameters.
EntityReference entity = (EntityReference)context.InputParameters["Target"];
}
OutputParameter
the OutputParameters property contains the data that is in the response message, Please note that only oputput parameter is populyaed only for post event
// Refer to the account in the task activity.
if (context.OutputParameters.Contains("id"))
{
//Get Id
}
Show/Hide “Customer Experience Improvement Program” in CRM for Outlook Plugin for users by default
Script can be used to configure CRM for outlook plugin from command line. You can pass configuration details using xml file to the script. Here is sample xml :
<Deployments>
<Deployment>
<DiscoveryUrl> http://Servername </DiscoveryUrl>
<Organizations>
<Organization IsPrimary='true'> organisation1 </Organization>
<Organization> organisation1 </Organization>
</Organizations>
<CEIPNotification> false </CEIPNotification>
</Deployment>
</Deployments>
XML node CEIPNotification can be used to Show/Hide Customer Experience Improvement Program
Here is sample command:
Tooltip Text
"<CRM installation path>\Client\ConfigWizard\Microsoft.Crm.Application.Outlook.ConfigWizard.exe" /i
"<CRM installation path>\Default_Client_Config.xml"
- <CRM installation path>
Default CRM installation path for 64 bit is C:\Program Files\Microsoft Dynamics CRM\
For 32-bit it C:\Program Files(86x)\Microsoft Dynamics CRM\
- /i ” C:\Program Files\Microsoft Dynamics CRM\Default_Client_Config.xml”
Is used to specify the location of xml config file
Refer to Install Microsoft Dynamics CRM for Outlook using a command prompt for further details about configuring CRM for outlook automatically.
Upcoming Microsoft Dynamics CRM 2016 Readiness Blitz
In preparation of upcoming release of Dynamics CRM 2016, Microsoft is hosting Dynamics CRM 2016 Readiness Blitz. Registration is free for Microsoft partners. There are two tracks:
Sales Track:
This will be three hour session offered at two time slots:
29 October 2015 07:00 to 10:00 PDT (convert to your local time)
29 October 2015 19:AM to 22:00 PDT (convert to your local time)
Technical Track:
This will also be three hour session offered at same two slots:
29 October 2015 07:00 to 10:00 PDT (convert to your local time)
29 October 2015 19:AM to 22:00 PDT (convert to your local time)
This is a good opportunity to gain better understanding of upcoming CRM release.
Click here for registration
Hello World!
Hello World!
Here I am starting this new blog about Dynamics CRM. This blog will focus mostly on Dynamics CRM implementation, customizations and Add ins and aim to post sample applications, code snippets and other tips and tricks. I’m hoping this blog will provide useful information.
Rubal