Skip to content

Tutorial 1

PhuocLe edited this page Aug 23, 2018 · 25 revisions

Task

  1. Lead can be import by Excel file and make sure the topic always uppercase after lead imported.

Coding

  1. Create a blank solution Paz.LuckeyMonkey
  2. Add New Project 10. C# Shared Project to solution Paz.LuckeyMonkey
    • PL.DynamicsCrm.DevKit created shared project name: Paz.LuckeyMonkey.Shared with the following folders, files
      • Entities
      • Lib
        • Date.cs
        • EntityBase.cs
        • Extension.cs
        • PluginCore.cs
        • SimpleJson.cs
  3. 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 dropdown Project Name
    • Select Lead in the Project Name
    • Select 9.0.2.4 in the Crm Version
      • PL.DynamicsCrm.DevKit get all Microsoft.CrmSdk.CoreAssemblies version from NuGet
    • Select 4.5.2 in the .Net version
    • Click OK
    • PL.DynamicsCrm.DevKit created plugin project name: Paz.LuckeyMonkey.Plugin.Lead
  4. Rebuild solution to restore NuGet packages
  5. Add 2. C# Plugin Class to Paz.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 entity Lead and bind to dropdown Message.
    • Select Message: Create - Stage: PreOperation. (It automatic selected Synchronous execution and not allow you change)
    • Click OK
    • PL.DynamicsCrm.DevKit created plugin class: PreLeadCreateSynchronous
  6. 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 to solution root folder
  7. Check solution root folder and you see 2 files: PL.DynamicsCrm.DevKit.json and PL.DynamicsCrm.DevKit.Cli.json
  8. 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"
  9. Rebuild solution
  10. Open command-line, go to Paz.LuckeyMonkey.Plugin.Lead folder, then run deploy.bat and waiting PL.DynamicsCrm.DevKit.Cli deploy to Dynamics Crm
  11. Open Plugin Registration Tool and verify plugin deployed
  12. Open Crm solution LuckeyMonkey and verify plugin Paz.LuckeyMonkey.Plugin.Lead added to Plug-in Assemblies node, step Paz.LuckeyMonkey.Plugin.Lead.PreLeadCreateSynchronous added to Sdk Message Processing Steps node
  13. Add 1. C# Late Bound Class to Entities folder of Paz.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 dropdown Class.
    • Select Lead in the class.
    • 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-generate Lead entity.
  14. Back to class: PreLeadCreateSynchronous and beginning code
    • Go to line 61 and code here
//YOUR PLUGIN-CODE GO HERE
var target = (Entity)context.InputParameters["Target"];
var lead = new Shared.Entities.Lead(target);
if (lead.Subject != null)
{
    lead.Subject = lead.Subject.ToUpper();
}

Note You can replace Target with InputParameters that PL.DynamicsCrm.DevKit created comment above to get an other InputParameters 13. Run deploy.bat again to deploy new code to your Dynamics Crm 14. Go to Dynamics 365, create new Lead to check plugin worked or not. 15. Check-in all files to your source control. 16. You finished this tutorial.

Clone this wiki locally