Download presentation
Presentation is loading. Please wait.
1
WRITING YOUR FIRST PLUGIN
Sarah Critchley | Cambridge Online Systems Ltd.
2
Headshot And/Or Company Logo
Speaker contact info Sarah Critchley Cambridge Online Systems Ltd Developer/Consultant BLOG: @dynamiccrmcat Headshot And/Or Company Logo 2
3
Introduction & AIMS – wHAT'S THIS SESSION ABOUT?
CONFIDENCE: Aim to focus on giving you confidence so you are not intimidated by all the information (and there is a lot, and it will be overwhelming) WHERE TO START: Direction as to where to start and where to move on to EMPOWERMENT: Empower you to continue and develop your skills and learning beyond this presentation and the initial 'excitement' of scope 3
4
What it is not about It won't make you an expert
You will always be learning and learn something new (Toolbox) It won't go into detail about best practices, this is conceptual and explanation for basic plugins and detail surrounding it Best practices mean nothing if you don't know what or why your doing something and why it is 'best‘ Not going to go into detail, ‘scratching the surface’ and where to start – This 45 minutes is about showing you that it is not difficult Basic code theory is covered and not assumed
5
Expanding Your own Toolbox!
With great power, comes great responsibility
6
SO WHAT ARE WE GOING TO DO?
7
To do MS Dynamics CRM Plugin Concepts Basic Code Theory
Breakdown of a Plugin Debugging your Plugin 7
8
MS Dynamics CRM Plugin Concepts
9
Plugin concepts What is a plugin? A way to extend the CRM Application
.Net - C# but also VB code Triggered on Events Create new functionality of modify existing functionality
10
What are these events? They are referred to as 'Messages'
Examples are Delete, Create, Update etc. A complete list can be found in the SDK CRM recognises these actions within the application and begins a pipeline of operations each time
11
a... pipeline of operations?
Commonly referred to as the 'Execution Pipeline': Pre-Validate Pre-Operation Core Operation Post-Event
12
A deeper dive into the pipeline
Input Output
13
A deeper dive into the pipeline
CRM APPLICATION Input Output Application Context (Target – the item being put into the process) The completed record after the pipeline has completed – it has saved to the database AND post operation has completed Only changed fields or fields that contain data are available on the ‘Target’ entity
14
A deeper dive into the pipeline
Only changed fields or fields that contain data are available on the ‘Target’ entity Images are used to capture more information about the item within the ‘input’ context that is not always available on the target Pre and Post images can be used to do this depending on the messages that are used (Create, Update etc) They act as ‘snapshots’ in time so you can utilise field values before and after the core application
15
Application Context (Target – the item being put into the process)
rollback Input Output Application Context (Target – the item being put into the process) The completed record after the pipeline has completed – it has saved to the database AND post operation has completed Only changed fields or fields that contain data are available on the ‘Target’ entity
16
summary Know the basic concepts of what a plugin is and what it does
How it is started and the basics what happens ‘under the hood’ through input and output Rollback and Images
17
Further research CRM SDK (here) MSDN and What’s New (here)
MSDN and Plugin Development (here)
18
Basic Code Theory
19
Objects and classes In code, we deal with objects
What are objects? An object is an instance of a class Right...so what is a class? A Class is a blueprint used to create objects A class has constructors (to create it) and methods (to do things with it) Those methods sometimes need more instructions to do things (arguments/parameters)
20
A VISUAL AND REAL REPRESENTATION
21
A visual and real representation
22
A visual and real representation
Car fordCar = new Car(); Class Car FordCar.colour = "red"; (Field) public string colour Personalise your object to your need (Method) travel(int distance) You want to 'do' things with your object! fordCar.travel(5)
23
A visual and real representation
Class Human We are all objects from a class of (Human) (Field) public string hairColour We all have attributes: Hair Colour, Size, Clothes, Jobs (these can change) (Method) drink(int cups) We all like to (do) something – these are methods!
24
Types of object Not going to cover different names, terminology or complexities of this yet, only core basics: You have some basic types of object made for you in the language e.g. String, Int and also Array. Some you don't have to always 'create'. You have some types for you in the CRM SDK made for you e.g. Entity, OptionSetValue You have your types you make from your own Classes that you create
25
Summary Basic code theory in relation to what you already know, entities and records! How this relates to code and basic programming with Class’s and Objects
26
Further research C# References:
27
Breakdown of a Plugin
28
So, lets look at some code!
But wait, how do you get there? Using VS2012 and the Dev Toolkit that comes with the CRM 2013 SDK, you can begin to get started with creating a plugin easily Note about the dev toolkit and later SDK versions
29
Steps to get started Install the Dev Toolkit (allows you to make CRM Projects and Items) New Package Add a new plugin solution View > CRM Explorer Click on an Entity and Select 'Create Plugin' Enter your Registration Details for the Message Create Success! You have made an empty plugin!
31
A note about the proceeding example
You won't use the same style everytime You might not even use all the objects It doesn't contain everything you can do (or like we said earlier, all best practices!) This is an illustrative example to get you started!
32
Lets take a look at one I made earlier
Setting up context, service and tracing Class (SDK) The object already exists, your just giving it a name!
33
Plugin breakdown Checking the target, the type and the name
Checking the Target exists and it is a type of Entity Explicit Conversion (cast) Risk of losing information, your saying this is 'OK' Tracing as an output in specific places, can also Trace variable values Checking the field exist before using them (remember about images and what the target contains – this is assuming a value was entered into the ‘day rate’ field)
34
Plugin breakdown Doing your stuff
Taking a value from a field in the Target Add tracing into nested Statements as you can See how far or what has been successful/hit Explicit Cast from a field in CRM (your code doesn't know what type this is!) so you need to specifically say 'This is the type I definitely want it to be' Setting a value of the Target entity (it will error if this is not a decimal type field too)
35
summary Looked at how to set up a Plugin Project
The breakdown of the actual code inside a plugin The use of inbuilt classes in the SDK and manipulating the CRM records passed through the pipeline as a ‘context’
36
Debugging your plugin
37
Why do I need to know how to debug?
This is a journey, which is fun, annoying, stressful and exciting Manage your own expectations: Your first few attempts will probably not work, THAT IS OKAY! It's very likely going to be something minor and small This is normal, don't beat yourself up about it It's about perseverance, debugging will help you see what is going on and allow you to get to know your code more
38
To debug Use the Plugin Registration Tool from the SDK
DEPLOY your plugin Open it Connect to your organisation Profile it Get the Profile by executing your plugin Load it into the tool Attach the Visual Studio Process Run! Walkthrough your code and look at the objects being created, their values, and everything about them!
40
summary Don’t be scared about debugging, the thought of not doing it takes longer than actually doing it Its amazing for learning and understanding what is going on It can be frustrating, don’t give up
41
Overall summary Basic plugin theory Basic code theory
Setup and Walkthrough of Plugin Code Debugging
42
Final tips on crm plugin dev
Gets something down (Blank Paper) Refactor Refactor again Debug (even if it's working) Don't take best practices on face value, learn why
43
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.