-
Notifications
You must be signed in to change notification settings - Fork 15
Tutorial 1
PhuocLe edited this page Sep 17, 2018
·
25 revisions
- Lead can be import by Excel file and make sure the topic always uppercase after lead imported
- Create a blank solution
Paz.LuckeyMonkey
- Add
New Project
10. C# Shared Project
to solutionPaz.LuckeyMonkey
-
PL.DynamicsCrm.DevKit
created shared project name:Paz.LuckeyMonkey.Shared
with the following folders, filesEntities
-
Lib
Date.cs
EntityBase.cs
Extension.cs
PluginCore.cs
SimpleJson.cs
-
- Add
New Project
03. C# Plugin Project
to solution.- A popup form
Add new Plugin Project
opened - Click button
><
to create/select a Dynamics 365 connection - After connected
PL.DynamicsCrm.DevKit
loaded all entities and bind to dropdownProject Name
- Select
Lead
in theProject Name
- Select
9.0.2.4
in theCrm Version
PL.DynamicsCrm.DevKit
get allMicrosoft.CrmSdk.CoreAssemblies
version fromNuGet
- Select
4.5.2
in the.Net version
- Click
OK
-
PL.DynamicsCrm.DevKit
created plugin project name:Paz.LuckeyMonkey.Plugin.Lead
- A popup form
- Rebuild solution to restore
NuGet
packages - Add
New Item
02. C# Plugin Class
toPaz.LuckeyMonkey.Plugin.Lead
project- A popup form opened
- Click button
><
to create/select a Dynamics 365 connection -
PL.DynamicsCrm.DevKit
load all messages plugin for entityLead
and bind to dropdownMessage
- Select
Message
:Create
-Stage
:PreOperation
. (It automatic selectedSynchronous
Execution
and not allow you change) - Click
OK
-
PL.DynamicsCrm.DevKit
created plugin class:PreLeadCreateSynchronous
- Open Windows Explorer, go to current solution folder, then goto
packages\tools\PL.DynamicsCrm.DevKit.Cli.[version]
folder. Copy file:PL.DynamicsCrm.DevKit.Cli.json
tosolution root folder
- Check solution root folder and you see 2 files:
PL.DynamicsCrm.DevKit.json
andPL.DynamicsCrm.DevKit.Cli.json
- Open file
PL.DynamicsCrm.DevKit.Cli.json
by Notepad and edit these information in section:plugins.profile = "DEBUG"
plugins.solution = "LuckeyMonkey"
plugins.includefiles = "Paz.LuckeyMonkey.*.dll"
- Rebuild solution then
right-click
ondeploy.bat
of projectPaz.LuckeyMonkey.Plugin.Lead
then selectExecute file
and waitingPL.DynamicsCrm.DevKit.Cli
deploy to Dynamics 365 - Open
Plugin Registration Tool
and verify plugin deployed - Open Dynamics 365 solution
LuckeyMonkey
and verify pluginPaz.LuckeyMonkey.Plugin.Lead
added toPlug-in Assemblies
node, stepPaz.LuckeyMonkey.Plugin.Lead.PreLeadCreateSynchronous
added toSdk Message Processing Steps
node - Add
New Item
01. C# Late Bound Class
toEntities
folder ofPaz.LuckeyMonkey.Shared
project.- A popup form opened
- Click button
><
to create/select a Dynamics 365 connection - After connected
PL.DynamicsCrm.DevKit
load all entities and bind to dropdownClass
- Select
Lead
in theClass
- Click
OK
and waiting, 2 files generated-
Lead.cs
you can edit/update your code here because it is a partial class. -
Lead.generated.cs
DON'T changes this file, it will be lost when you re-generateLead
entity
-
- Back to class:
PreLeadCreateSynchronous
and edit code like bellow
private void ExecutePlugin(IPluginExecutionContext context, IOrganizationServiceFactory serviceFactory, IOrganizationService service, ITracingService tracing)
{
//var target = (???)context.InputParameters["Target"];
//var preEntity = (Entity)context.PreEntityImages["PreImage"];
//var postEntity = (Entity)context.PreEntityImages["PostImage"];
//YOUR PLUGIN-CODE GO HERE
LeadSubjectAlwaysUppercase(context, service, tracing);
}
private void LeadSubjectAlwaysUppercase(IPluginExecutionContext context, IOrganizationService service, ITracingService tracing)
{
Debugger.Trace(tracing, "BEGIN LeadSubjectAlwaysUppercase");
var target = (Entity)context.InputParameters["Target"];
var lead = new Shared.Entities.Lead(target);
if (lead.Subject != null)
{
lead.Subject = lead.Subject.ToUpper();
}
Debugger.Trace(tracing, "END LeadSubjectAlwaysUppercase");
}
Note
You can replace Target
with InputParameters
that PL.DynamicsCrm.DevKit
created comment above to get an other InputParameters
- Run
deploy.bat
again to deploy new code to your Dynamics 365 - Go to Dynamics 365, do an import
Lead
to check topic always uppercase after lead imported - Check-in all files to your source control
- You finished this tutorial
This tutorial, you know howto
- Add
10. C# Shared Project
- Add
03. C# Plugin Project
- Add
01. C# Late Bound Class
- Add
02. C# Plugin Class
- Config
PL.DynamicsCrm.DevKit.Cli.json
forPlugins