Tuesday, January 31, 2012

How to view Ribbon Definitions in CRM 2011

  The latest SDK did not include the ribbon definition XML files forcing you to build and run an app from source code provided in order to generate them for your self. The following link (Tucker's Microsoft CRM Blog) provide information on this process


Click Here

Microsoft.Xrm.Sdk.dll is not detecting


When we create a console application for CRM 2011


if the Microsoft.Xrm.Sdk is not detecting then make sure that the
Traget in the properties is set to ".NET Framework 4" instead of ".NET Framework Client Profile"

How to create a contact of CRM through a simple Web page

here is a link which shows How to create a contact record of CRM 2011  through a simple Web page

Click Here...


Try This  :)

Monday, January 30, 2012

Trigger a Plug-in From a Ribbon Button in Microsoft Dynamics CRM 2011

Dear Friends ,

  Today i was browsing through the msdn and i have seen a post of Jamie Miley about Trigger a Plug-in From a Ribbon Button in Microsoft Dynamics CRM 2011 guys its intresting and here is the link of that post

Jamie Miley MSDN

Try this ....

Friday, January 27, 2012

Pass Data between Plug-Ins


The message pipeline model defines a parameter collection of custom data values in the execution context that is passed through the pipeline and shared among registered plug-ins, even from different 3rd party developers. This collection of data can be used by different plug-ins to communicate information between plug-ins and enable chain processing where data processed by one plug-in can be processed by the next plug-in in the sequence and so on. This feature is especially useful in pricing engine scenarios where multiple pricing plug-ins pass data between one another to calculate the total price for a sales order or invoice. Another potential use for this feature is to communicate information between a plug-in registered for a pre-event and a plug-in registered for a post-event. 
The name of the parameter that is used for passing information between plug-ins is SharedVariables. This is a collection of key\value pairs. At run time, plug-ins can add, read, or modify properties in the SharedVariables collection. This provides a method of information communication among plug-ins.
The name of the parameter that is used for passing information between plug-ins is SharedVariables. This is a collection of key\value pairs. At run time, plug-ins can add, read, or modify properties in the SharedVariables collection.
This sample shows how to use SharedVariables to pass data from a pre-event registered plug-in to a post-event registered plug-in.



using System;
// Microsoft Dynamics CRM namespace(s)
using Microsoft.Xrm.Sdk;
namespace Microsoft.Crm.Sdk.Samples
{
///

/// A plug-in that sends data to another plug-in through the SharedVariables
 /// property of IPluginExecutionContext.
 ///
 /// Register the PreEventPlugin for a pre-event and the
 /// PostEventPlugin plug-in on a post-event.
 ///
//Preevent Plugin
 public class PreEventPlugin : IPlugin
  {
   public void Execute(IServiceProvider serviceProvider)
   {
    // Obtain the execution context from the service provider.
    Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext)
   serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));
    // Create or retrieve some data that will be needed by the post event
    // plug-in. You could run a query, create an entity, or perform a calculation.
  //In this sample, the data to be passed to the post plug-in is
   // represented by a GUID.
   Guid contact = new Guid("{74882D5C-381A-4863-A5B9-B8604615C2D0}");
  // Pass the data to the post event plug-in in an execution context shared
   // variable named PrimaryContact.
   context.SharedVariables.Add("PrimaryContact", (Object)contact.ToString());
   }
 }

 //Post Event Plugin
public class PostEventPlugin : IPlugin
  {
   public void Execute(IServiceProvider serviceProvider)
    {
     // Obtain the execution context from the service provider.
     Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext)
     serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));
     // Obtain the contact from the execution context shared variables.
    if (context.SharedVariables.Contains("PrimaryContact"))
      {
       Guid contact =new Guid((string)context.SharedVariables["PrimaryContact"]);
     // Do something with the contact.
       }
     }
  }
}

Thursday, January 26, 2012

Understand the Data Context Passed to a Plug-In



IPluginExecutionContext contains information that describes the run-time environment that the plug-in is executing in, information related to the execution pipeline, and entity business information. The context is contained in the System.IServiceProvider parameter that is passed at run-time to a plug-in through its Execute method.

// obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
 serviceProvider.GetService (typeof (IPluginExecutionContext));

The execution context is passed to each registered plug-in in the pipeline when they are executed. Each plug-in in the execution pipeline is able to modify writable properties in the context. For example, given a plug-in registered for a pre-event and another plug-in registered for a post-event, the post-event plug-in can receive a context that has been modified by the pre-event plug-in. The same situation applies to plug-ins that are registered within the same stage.
All the properties in IPluginExecutionContext are read-only. However, your plug-in can modify the contents of those properties that are collections.


Access to the Organization Service

To access the Microsoft Dynamics CRM organization service, it is required that plug-in code create an instance of the service through the ServiceProvider.GetService method.
// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory) 
serviceProvider.GetService (typeof (IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService (context.UserId);

Input and Output Parameters


The InputParameters property contains the data that is in the request message currently being processed by the event execution pipeline. Your plug-in code can access this data. The property is of type ParameterCollection where the keys to access the request data are the names of the actual public properties in the request. As an example, take a look at CreateRequest. One property of CreateRequest is named Target which is of type Entity. This is the entity currently being operated upon by the platform. To access the data of the entity you would use the name “Target” as the key in the input parameter collection. You also need to cast the returned instance.
// 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"];
 
Similarly, the OutputParameters property contains the data that is in the response message, for example CreateResponse, currently being passed through the event execution pipeline. However, only synchronous post-event and asynchronous registered plug-ins have OutputParameters populated as the response is the result of the core platform operation. The property is of type ParameterCollection where the keys to access the response data are the names of the actual public properties in the response.


Pre and Post Entity Images


PreEntityImages and PostEntityImages contain snapshots of the primary entity's attributes before and after the core platform operation. Microsoft Dynamics CRM populates the pre-entity and post-entity images based on the security privileges of the impersonated system user. You can specify to have the platform populate these properties when you register your plug-in. The entity alias value you specify during plug-in registration is used as the key into the image collection.
There are some events where images are not available. For example, only synchronous post-event and asynchronous registered plug-ins have PostEntityImages populated. In addition, the create operation does not support a pre-image and a delete operation does not support a post-image.
Note: - Registering for pre or post images to access entity attribute values results in improved plug-in performance as compared to obtaining entity attributes in plug-in code through RetrieveRequest or RetrieveMultipleRequest requests.
Only entity attributes that are set to a value or null are available in the pre or post entity images

Wednesday, January 25, 2012

Plugin Message And Entity Combination in CRM 2011


The following Link lists the message and entity combinations that support synchronous and asynchronous plug-ins. This table is also available as an Excel worksheet complete with column filtering at SDK\Tools\Plug-in Message-Entity Table.xls.


http://msdn.microsoft.com/en-us/library/cc151101.aspx


Note    To trigger a plug-in on a state change, register the plug-in on both the SetState and SetStateDynamicEntity messages.
Note    To trigger a plug-in when the Web application retrieves entity data to populate a grid view, register the plug-in on both the Execute and RetrieveMultiple messages with no primary entity specified.


Tuesday, January 24, 2012

Register your plug-in with the Plug-in Registration Tool in CRM 2011


1) Run the Plug-in registration tool you can find in SDK\Tools\PluginRegistration\          if you have not already built this tool; build the Plug-in Registration Tool according to the instructions in its Readme file, located at SDK\Tools\PluginRegistration\Readme.docx.

2) Click Create New Connection.

Register the plug-in

3) In the Connections panel, enter a descriptive label for the connection. Fill in the other fields as appropriate for your Microsoft Dynamics CRM server.
4) Click Connect. A connection to the server is established and a list of available organizations for the specified system account is displayed.
5) Double-click the desired organization in the connections list. The list of all assemblies, steps, and plug-ins currently registered for the target organization is displayed.

Browse to your organization's plug-in list

6) Click Register New Assembly.

Register new assembly

7)  In the Register New Plug-in dialog box, click the ellipsis button (…) and navigate to the location of your plug-in assembly. Select the assembly and make sure that all plug-ins under it are selected.
8) Select None for the isolation mode. Note that Developer Extensions for Microsoft Dynamics CRM currently does not support the sandbox isolation mode. Verify that the Database option is selected so that the plug-in will be stored in your organization’s database.
9) Click Register Selected Plug-in.

Register plug-in
   
  
10) Click OK.

    Plug-in registered

11) Expand the assembly and select the plug-in that you just registered. Select Register, and then click Register New Step.

Register new step

12) In the Register New Step dialog box, enter the Microsoft Dynamics CRM message that the step will be registered under. In this example, type “Create”. Under Primary Entity, type “contact”. Leave the Pipeline stage set to Post Stage, execution mode to Synchronous, and other options set to default. Click Register New Step.

Register new step

13) The registered step appears under the plug-in

Step registered successfully

14) Test the plug-in by creating a new contact in Microsoft Dynamics CRM. After you have saved the entity, a note should be attached.

Plugin In CRM 2011


      1)      Create a new class library project in Microsoft Visual Studio as shown here. This sample uses “Plug-in” as the project name
Create project in Visual Studio

2        2)      Add the following references from the SDK\bin folder.
  • Microsoft.Xrm.Client.dll
  • Microsoft.Xrm.Sdk.dll
     3) Add the following .NET references.
  • Microsoft.IdentityModel.dll
  • System.Data.Services
  • System.Data.Services.Client
  • System.Runtime.Serialization
  • System.ServiceModel
If you do not have the Microsoft.IdentityModel.dll file, you must install Windows Identity Foundation.

4)  Right-click the project in Visual Studio, clicks Add, and then clicks Existing Item.
5) Select the “xrm.cs” file that you created when you generated the early bound types.
Sign your plug-in project
It must that you have to sign in your plug-in before registering the   plug-in.
Here are the steps for signing a plug-in
Add a strong key to your project
1) Open the properties pane under your plug-in project.
                     Open properties pane
2) Create a new strong key file by clicking the Signing tab, select the Sign the assembly check box and select in the drop down list.
Create strong key

3) Type a name for your strong key (in this example, it is “PluginWalkthrough”) and clear the”Protect my key file with a password” check box before clicking OK.


Create a strong name key


4) Save your changes.

Create the plug-in that will run your code

1) Right-click your project again, clicks Add, and then clicks New Item.
2)  Select Class from the options, type the name “Plugin.cs”, and then click Add.

Create a plugin

3) Add the following code to the Plugins.cs file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Client;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Data.Services;
using System.Data.Services.Client;
using System.Diagnostics;
using Xrm;

namespace Sampleplugin
{
    public class plugin : IPlugin
    {
        public void Execute(IServiceProvider serviceProvider)
        {
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            Entity entity;
            // Check if the input parameters property bag contains a target
            // of the create operation and that target is of type Entity.
            if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
            {
                // Obtain the target business entity from the input parameters.
                entity = (Entity)context.InputParameters["Target"];
                // Verify that the entity represents a contact.

                try
                {
                    IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                    IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
                    Annotation annotation = new Annotation();
                    annotation.ObjectId.Id = entity.Id;
                    annotation.ObjectId.LogicalName = entity.LogicalName;
                    annotation.ObjectTypeCode = entity.LogicalName;
                    annotation.NoteText = "This added by the plugin ";
                    service.Create(annotation);
                }
                catch (FaultException ex)
                {
                    throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
                }
            }


        }
    }
}

4) Build the solution.
5) We can find the  .dll in Debug/bin folder of your project folder


Some Usefull Tools in CRM 2011

      Today i was browsing through blog in that i found so many tools which will use full ...
here i have listed  the links  of some tools


http://ribbonbrowser.codeplex.com/  -Ribbon Browser for Microsoft Dynamics CRM 2011
http://viewlayoutreplicator.codeplex.com/  -View Layout Replicator for Microsoft Dynamics CRM 2011
http://ribboneditor.codeplex.com/  -Ribbon Editor
http://jswebresourcemanager.codeplex.com/  -JavaScript Web Resource Manager for Microsoft Dynamics CRM 2011
http://sitemapeditor.codeplex.com/   - Ribbon Editor for Microsoft Dynamics CRM 2011
http://roleupdater.codeplex.com/  - Role Updater for Microsoft Dynamics CRM 2011
http://solutionimport.codeplex.com/  - Solution Import for Microsoft Dynamics CRM 2011
http://searchpropupdater.codeplex.com/  -Searchable Property Updater for Microsoft Dynamics CRM 2011

Reference:- http://mscrmtools.blogspot.com/2011/01/crm-2011-plugins-welcome-to.html

Dynamics CRM 2011 Developer Training Kit

Here is the link to Download

Dynamics CRM 2011 Developer Training Kit

 http://www.microsoft.com/download/en/details.aspx?id=23416 

I  hope it will be help full ...