Here is link to Sam’s blog that explains each project in developer’s toolkit. MSDN blog also have similar contents. In this blog I am going to create a sample plugin using developer’s toolkit. It is a copy of one of my earlier blog(Step by step plugin tutorial for CRM 2011) .
Install the developer’s toolkit.The Developer toolkit for Microsoft Dynamics CRM 2011 was released as part of UR5 SDK release and is available for download here.
- Create a new solution in CRM2011. I named my solution “CRM Plugin Solution”. This is optional but I would recommend you do that.
- Open Visual Studio 2010. Select File—New –Project. It will display new project templates dialog as shown in the screen sheet below
- Select “Dynamics CRM 2011 Package” project. This is also optional. You can go ahead and select “Dynamics CRM 2011 Plugin Library”, But then you cannot deploy the plugin straight from the Visual Studio. You have to use Plugin Registration tool to register the plugin. Enter the name of project/solution.
- VS studio will display following dialog.Enter you CRM 2011 server details.Select the solution name we created in step 1 and click ok
- Now right click on the solution and add “Dynamics CRM 2011 Plugin Library” project to the solution. The plugin project will already have a plugin.cs file.
- Now sign the plugin assembly. Right click on Plugin Project and select properties. Select Signing tab from left navigation of project property page. On the Signing tab, select the Sign the assembly check box and set the strong name key file of your choice.At a minimum, you must specify a new key file name. Do not protect your key file by using a password.
- If You cannot see the “CRM Explorer” window on the upper left side of the VS studio, click on View menu and select “CRM Explorer”.
- Now expand “Entities” Node. Right Click the entity on want to create the plugin for and select “Create Plugin”.
- It will display a following screen.It is equivalent to “Create Step” screen in plugin registration tool. The dialog will pick up the name of the entity and other information. Choose the message and the pipeline stage. You can also change of the Class attribute. Press Ok.
- It will create a .cs file with name mentioned in “Class” attribute in screen shot above. Double click on the class file(PostAccountCreate) and scroll down to following lines of code. You write your business logic here.
protected void ExecutePostAccountCreate(LocalPluginContext localContext) { if (localContext == null) { throw new ArgumentNullException("localContext"); } // TODO: Implement your custom Plug-in business logic. }
- The first thing you will do is to get the plugin context, CRMService instance and TracingService instance using localContext passed to the function. All these objects are defined in the built in plugin.cs class.
IPluginExecutionContext context = localContext.PluginExecutionContext; IOrganizationService service = localContext.OrganizationService; //ITracingService tracingService = localContext.TracingService;
- Here is code. It will check if the “account number” is null or empty and create a task for a user to enter the account number.
protected void ExecutePostAccountCreate(LocalPluginContext localContext) { if (localContext == null) { throw new ArgumentNullException("localContext"); } // TODO: Implement your custom Plug-in business logic. // Obtain the execution context from the service provider. IPluginExecutionContext context = localContext.PluginExecutionContext; IOrganizationService service = localContext.OrganizationService; //ITracingService tracingService = localContext.TracingService; // The InputParameters collection contains all the data passed in the message request. if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { // Obtain the target entity from the input parmameters. Entity entity = (Entity)context.InputParameters["Target"]; //EntityReference pp = entity.GetAttributeValue
I also left few commented lines in the code to show “How to use tracingservice to write in trace log”. You will able to see the trace only if there is an error in the plugin.("primarycontactid"); //tracingService.Trace(pp.LogicalName); try { //check if the account number exist if (entity.Attributes.Contains("accountnumber") == false) { //create a task Entity task = new Entity("task"); task["subject"] = "Account number is missing"; task["regardingobjectid"] = new EntityReference("account", new Guid(context.OutputParameters["id"].ToString())); //adding attribute using the add function // task["description"] = "Account number is missng for the following account. Please enter the account number"; task.Attributes.Add("description", "Account number is missng for the following account. Please enter the account number"); // Create the task in Microsoft Dynamics CRM. service.Create(task); } } catch (FaultException ex) { throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex); } } } - Now right click on CRM Package project we created in step 2 and select deploy. It will register the plugin assembly as well as step for the plugin. Click on CRM Explorer to check the deployed plugin as shown in the following screen shot.
- Create a new account and test the plugin.
Nice tutorial on using the Developer's Toolkit Singh! I was just starting to look at the SDK when I ran across your post. It saved me quite a bit of time and simplified both the creation and deployment of several plugins!
ReplyDeleteThanks for the feedback. I m glad it helped.
DeleteSingh is king .. Great stuff Amreek
DeleteThis was a really great contest and hopefully I can attend the next one. It was alot of fun and I really enjoyed myself.. https://jsongrid.com/json-formatter
DeleteThanks for the tutorial!
ReplyDeleteWhen I attempt to create the plug-in by hitting the OK button from the "create plug-in" window in step 9, I get the error: "Length cannot be less than zero. Parameter name: length"
Any help is appreciated.
...i needed to save the solution first. Sorry to bother! Great Tutorial!! thanks again.
DeleteNo problem. thanks mate.
ReplyDeleteHi, I tried to use the code above with difference being in updating a record instead of creating one. However, when I tried to update, an error regarding infinite loop settings comes up. I did a bit of readup on this and have increased the setting to 100 (8 being default I read). However, the update just times out with an SQL error. Could you please point me in the right direction? Thanks heaps.
ReplyDeleteIf you are registering a plugin on post update event and updating the same entity. It is going to get stuck in the loop. I would suggest, if you are updating entity, which is triggering the plugin then register it on pre update.
DeleteOther options are use Depth attribute of the context
or
use filtering as mentioned in my my blog http://mscrmshop.blogspot.com.au/2012/02/use-of-filtering-attributes-during.html
I hope this helps.
Thanks for the good tutorial! I am unable to debug the plug-in exist in the solution. how I can debug the solution.
ReplyDeletetry these steps
ReplyDeletehttp://msdn.microsoft.com/en-us/library/gg328574.aspx
I hope this helps.
Hi,
ReplyDeletehow to connect the Online MS CRM 2011?, can u post an example screen shot for online MS crm 2011 connection details.
thanks
suray kathir
Put your URL like inv.crm5.dynamics.com,
ReplyDeleteremove 80 from the port text box.
choose https and press connect
This comment has been removed by a blog administrator.
ReplyDeleteHi Singh
ReplyDeleteVery nice tutorial, thanks for sharing .
I have a question , can you please tell me where the plugin assembly will be register? will it be on the crm server or the database or somewhere else?
I am asking because although i have the admin role in my organisation we (the org)have an "on-Premise" Licence and actually we are not allow to register plugins on the CRM Server since there are also other companies present on the Server. Surprisingly for me i was able to follow all the steps of this tutorial and register the plugin. I can see the registered Plugins unther the setting options with a Deployement type of sandbox
Thanks a lot for your help
Sandbox is a isolated environment. You generally run the plugins in a sandbox where you don't have permission to deploy the plugin on the server or database foe e.g. mscrmonline.
ReplyDeleteHave a look at this link http://msdn.microsoft.com/en-us/library/gg334752.aspx. In short, your plugin is running on the machine that is running a Microsoft.Crm.Sandbox.HostService.exe process.
Microsoft Dynamics CRM training will help you manage and prioritize your business goals, customize.we teach MS Dynamics CRM training and class available at Hyderabad.
ReplyDeleteHi when i try to deploy i get
ReplyDeleteError 1 Error connecting to CRM Server. The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs. D:\Program Files (x86)\MSBuild\Microsoft\CRM\Microsoft.CrmDeveloperTools.CrmClient.targets
Did you ever find a resolution to this, I am now getting the same error?
DeleteThis comment has been removed by the author.
DeleteAfter building the app, when tries to deploy, getting following error.
ReplyDeleteError registering plugins and/or workflows. Plug-in assembly does not contain the required types or assembly content cannot be updated.
had u get the reason ...i am getting same error
DeleteTry this
Deletehttp://gonzaloruizcrm.blogspot.com.au/2012/08/crm-2011-plug-in-assembly-does-not.html
Thanks
How to install Developer Toolkit for VS 2012 RC? Actually, I've installed it successfully, but there is no "Dynamics CRM" node in my project templates dilog box.
ReplyDeleteWhen I try to deploy , it gives me following error:
ReplyDelete"Error registering plugins and/or workflows. An unexpected error occurred. ...\Microsoft.CrmDeveloperTools.CrmClient.targets"
Please help me out.
thanks a lot for this tutorial. I am beginners to words ms crm. This tutorial give a good idea on plugin with in few time....
ReplyDeletethanks again :)
I m glad it helps.
DeleteThanks
Hi,
ReplyDeleteI want to retireve the "names" of existing account's from online crm. How do i do this?? Please help me.....
Truly remarkable labor with the blog. I do like your inflexible service and will wait for more post from you as post gave me gratification and gives some helps to do same work right here. Thanks a lot.Private equity Placement
ReplyDeleteThanks mate.
ReplyDeleteHi,
ReplyDeleteIs there any way to change the deployment target of the existing package project? For e.g., currently I have pointed it to my development server and now I want to deploy it on my QA server....how to change the deployment target?
Thanks!
5. Now right click on the solution and add “Dynamics CRM 2011 Plugin Library” project to the solution. The plugin project will already have a plugin.cs file.
ReplyDelete6. Now sign the plugin assembly. Right click on Plugin Project and select properties. Select Signing tab from left navigation of project property page. On the Signing tab, select the Sign the assembly check box and set the strong name key file of your choice.
Can you explain these steps? I can not find this. My degree of knowledge in developing plugins, this is my first one.
I have the same question,
DeleteI have an issue with CRM Explorer, I am giving server name , username,password,domain name and selecting organization...but the solution drop-down is disabled and as soon as I select organization the dialogue box is getting disappeared. Any help to resolve this please...
ReplyDeleteHi, thanks for this great stuff, excellent post regarding to microsoft dynamics crm tutorial.
ReplyDeleteThanks mate.
DeleteHey thanks for informing me about the basic steps in a developer toolkit.........This was really helpful for me.
ReplyDeleteCRM Development
No problem mate.
DeleteHi Im new to CRM and have been tryng to adapt your brilliant tutorial so that when a record is created in a contatc entity, a csv file is generated. gan you give me any pointers on this
ReplyDeleteHi, I'm using VS2012 and when deploying my plugin from VS, none of my steps are been registered and if I right-click on my now deployed plugin in the CRM Explorer, the "add step" functionality doesn't exist. Any thoughts? Thanks.
ReplyDeleteVS2012 and the DevKit didnt register my plugins properly, had to use the Plugin Reg Tool.
DeleteVery strange.
Have any thoughts as to why VS didn't register my plugins?
Thanks
Hi, I was following the steps for Plugin Development in CRM in your post and it's very easy to follow.
ReplyDeleteThanks a lot
Nice tutorial, but no idea how to perform step 5 :
ReplyDelete"Now right click on the solution and add “Dynamics CRM 2011 Plugin Library” project to the solution. The plugin project will already have a plugin.cs file."
Do you mean, add New Item, Add existing item or Add reference ?
Solved it and works like a charm !!
DeleteBefore perfoming step 5
- make sure you've also created an empty plugin-project
- in VS2012 be sure to check : options -> Projects and solutions -> General -> Always show solution !!
- now you can perform step 5 right-click on solution -> add.. -> existing project -> pick the empty plugin project you've created for this purpose
Thanks for sharing Rob
DeleteHi Amreek nice article, Thank's for this helpful information
ReplyDeletevery nice blog !
ReplyDeletecertainly nice place to learn how to create a first Plugin.
Thanks for information.find the information what i need about Dynamics AX Online Training|Microsoft Dynamics CRM Training|Sharepoint Online Training
ReplyDeleteThanks for sharing a best informetion
ReplyDeleteCRM Development Dubai:ERP Development Dubai
Hey nice blog,Thanks a lot for this useful and helpful information.Thanks a lot for this tutorial. I found some good information on https://www.evello.com.au/.
ReplyDelete
ReplyDeleteI just wanted to say that I really appreciate your posts.
Oracle Fusion Financials Online Training
Thanks for the Tutorial...But i don't Know Why the Solution name is not showing after choosing the Organization name in visual studio 2012..help me plz..
ReplyDeleteI do acknowledge with all of the perceptions you have imported in your post. They’re really impressive and will definitely work. Still, the posts are very brief for starters. May you please enhance them a little from subsequent time? Gratitude for the post.
ReplyDeleteMicrosoft Dynamic CRM Development Company
Can you please update this tutorial for the latest version of Microsoft Dynamic CRM.
ReplyDeleteBest article i have every seen. Keep up the great work man.
ReplyDeleteTake a look at our CRM Development.
It's A Great Pleasure reading your Article, learned a lot of new things, we have to keep on updating it Mini Militia Pro Pack Hack Apk, Mini Militia hack Version Thanks for posting.
ReplyDeleteI would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.
ReplyDeleteTelephony System
Mobile Device
ted
ReplyDeleteA bewildering web journal I visit this blog, it's unfathomably heavenly. Oddly, in this present blog's substance made purpose of actuality and reasonable. The substance of data is informative
Oracle Fusion Financials Online Training
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training
Great post! I am actually getting ready to across this information, It's very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
ReplyDeleteHealth Care Tipss
All Time With You
Article Zings
Article Zings
Article Zings
Article Zings
Article Zings
Article Zings
Health Carinfo
A befuddling web diary I visit this blog, it's incredibly grand. Strangely, in this present blog's substance made motivation behind fact and sensible. The substance of information is instructive
ReplyDeleteThanks For Sharing
Types Of Obesity
Expensive Workout Equipment
Blood Pressure and Weight
Successful Journey Through Recovery
homemade laxatives
Deal With Stress
How Much Do You Really Owe Your Ex?
Can Mangosteen Cure Diabetes
You rock man.. seriously man from where do you find such info to write about.. many thanks for sharing
ReplyDeletetreatment of glaucoma
Eating Habits
Skin Care Products
At Home to Save Money
Lose that Unwanted Fat
Incorporate Wellness
Wellness More of a Priority in Your Office
Good Information Thanks for Sharing
ReplyDeleteSoft Online Provides best online training for Oracle Fusion and EBS R12 Courses
Oracle EBS Training in Hyderabad
Oracle Fusion SCM Training
Oracle Fusion HCM Training
Oracle Fusion Financials Training
For more info Visit us: https://www.softonlinetraining.com/
Useful tutorial! Check my guide on CRM creation process - https://www.cleveroad.com/blog/how-to-build-your-own-crm-system-avoiding-common-mistakes
ReplyDeleteThanks for sharing the great post and useful information. This post is really helpful for me. I would like to tell you that If you want to take server hosting services then Onlive Server is the best option. our Dubai VPS Server one of the best hosting options.
ReplyDeleteThank You...
This comment has been removed by the author.
ReplyDeleteGreat tutorial! Check my guide for CRM which boosting converstions - for gym crm system for health clubs
ReplyDeleteThank you for this useful tutorial. It has information that can help you to solve some problems with software development. And here you can hire crm developers https://joinsoft.com/services/your-tech-partner-for-custom-crm-development/
ReplyDelete
ReplyDeleteSuch an informative post. Thank you for sharing
Online Project Server Solution
Si estás buscando una herramienta de gestión de relaciones con clientes, útil para organizar la información de contacto y rastrear interacciones, tenemos lo que estás buscando. CRM En WolfCRM ofrecemos planes de programming de CRM para la gestión de tu empresa
ReplyDelete
ReplyDeleteI am very impressed with your post because this post is very beneficial for me and provide a new knowledge to me
instance Plugin
Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care. We are also providing the best services click on below links to visit our website.
ReplyDeleteOracle Fusion HCM Training
Workday Training
Okta Training
Palo Alto Training
Adobe Analytics Training
Impressive and powerful suggestion by the author of this blog are really helpful to me.DP-080: Querying Data with Microsoft Transact-SQL
ReplyDelete