Thursday, June 2, 2011
Friday, April 8, 2011
List of changes in plugin development in CRM 4.0 and CRM 2011
There are not much changes in terms of plugins. there are few changes like instead of using DynamicEntity class we have to use the Entity class. the five major changes are :
1. The IPlugin now resides in Microsoft.Xrm.Sdk namespace instead of Microsoft.Crm.Sdk
public class ClassName : Microsoft.Crm.Sdk.IPlugin
public class ClassName : Microsoft.Xrm.Sdk.IPlugin
2. The Execute method signature of the IPlugin interface has changed, it now expects an IServiceProvider instead of the IPluginExecutionContext.
public void Execute(IPluginExecutionContext context)
public void Execute(IServiceProvider serviceProvider)
3. To get a reference to the IPluginExecutionContext you now need to call the GetService method of the IServiceProvider interface.
public void Execute(IPluginExecutionContext context)
Microsoft.Xrm.Sdk.IPluginExecutionContext context =(Microsoft.Xrm.Sdk.IPluginExecutionContext)
serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));
4. ICrmService has been changed to IOrganizationService.
ICrmService sdk = context.CreateCrmService(true);
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService sdk = factory.CreateOrganizationService(context.UserId);
5. DynamicEntity has been changed to Entity.
- Properties property of DynamicEntity no longer exists
- Getting and Setting values no longer use *Property classes,
eg: no more KeyProperty, StringProperty…etc, simply do int value = (int)entity[“schema_name”];
if (context.InputParameters.Properties.Contains("Target") &&
context.InputParameters.Properties["Target"] is DynamicEntity)
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)hats off to the original contribution by Gayan Perera
Happy Coding
List of changes : Type mapping between CRM 4.0 and CRM 2011
In Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online, the programming model has been changed to use native .NET types whenever possible. A beautiful post from Resultondemand explains it all, with all credit to their great job the excerpts of the post is :
Type Mapping Between Versions
The following table shows the mapping between the defined type for an entity attribute, the type that is used in a record, and the type that was used in Microsoft DynamicsCRM4.0.
| Attribute Type | Microsoft Dynamics CRM 2011 Type | Microsoft DynamicsCRM4.0 Type |
| AttributeTypeCode.Boolean | bool or System.Boolean | CrmBoolean |
| AttributeType.CalendarRules | EntityCollection | DynamicEntity[] or calendarrule[] |
| AttributeType.Customer | EntityReference | Customer |
| AttributeType.DateTime | System.DateTime | CrmDateTime |
| AttributeType.Decimal | decimal or System.Decimal | CrmDecimal |
| AttributeType.Double | double or System.Double | CrmFloat |
| AttributeType.Integer | int or System.Integer | CrmNumber |
| AttributeType. Internal | System.Object Not used in records. | Not used in records. |
| AttributeType.Lookup | EntityReference | Lookup |
| AttributeType.Memo | string or System.String | System.String |
| AttributeType.Money | Money | CrmMoney |
| AttributeType.Owner | EntityReference | Owner |
| AttributeType.PartyList | EntityCollection or ActivityParty[] | activityparty[] or DynamicEntity [] |
| AttributeType.Picklist | OptionSetValue | Picklist |
| AttributeType.PrimaryKey | System.Guid | Key |
| AttributeType.String | System.String | System.String |
| AttributeType.State | OptionSetValue or enumeration generated for the entity state | EntityNameStateInfo |
| AttributeType.Status | OptionSetValue orint | Status |
| AttributeType.Uniqueidentifier | System.Guid | UniqueIdentifier |
| AttributeType.Virtual | System.Object Not used in records. | Not used in records. |
List of changes in JavaScript usage in CRM 4.0 and CRM 2011
When working with CRM2011 Java script you will found many difference about syntax/methods between CRM2011 and CRM4.0 Please check some of the comparisons as listed. Please click on the Image below to enlarge view. hats off to the original post contributor.
Happy Coding
List of changes in Custom Workflow Assembly in CRM 4.0 and CRM 2011
here is a a quick list of changes you need to remember while creating workflow assemblies in CRM 4.0 or CRM 2011, as found here.
1. References
CRM 4.0
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Compiler;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Query;
using Microsoft.Crm.SdkTypeProxy;
using Microsoft.Crm.Workflow;
CRM 2011
using System.Activities;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
2. Base Class
Base class definition has been changed from SequenceActivity to CodeActivity.
CRM 4.0: In CRM 4.0 we have to specify both Workflow name and Workflowactivitygroupname in the code as written in the following code.
[CrmWorkflowActivity("My Custom Workflow", "CRM Workflow")]
public class MyCustomWF: SequenceActivity
CRM 2011: In CRM 2011 that is done in different way.
public class MyCustomWF: CodeActivity
Both Workflow name and Workflowactivitygroupname can be specified at the time of registering the assembly
3. Execute Method
The overridden Execute method remains the same except parameter and return type.
CRM 4.0
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
CRM 2011
protected override void Execute(CodeActivityContext executionContext)
4. Create service
CRM 4.0
IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));
IWorkflowContext context = contextService.Context;
ICrmService crmService = context.CreateCrmService();
CRM 2011
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
5. INPUT Parameters
CRM 4.0
Declaration: how to initialize the input parameter
// specified dependency property
public static DependencyProperty CaseIDProperty = DependencyProperty.Register("CaseID", typeof(Lookup), typeof(TotalTaskRetrieval));
// Specified Input property
[CrmInput("Enter Case ")]
// Set the reference Target for Property created
[CrmReferenceTarget("incident")]
// Property Defined for caseId
public Lookup CaseID
{
get
{
return (Lookup)base.GetValue(CaseIDProperty);
}
set
{
base.SetValue(CaseIDProperty, value);
}
}
Use: Access the input parameter declared above as,
Guid caseid=CaseID.Value
CRM 2011
Declaration: how to initialize the input parameter
[Input("Enter Case ")]
[ReferenceTarget("incident ")]
[Default("3B036E3E-94F9-DE11-B508-00155DBA2902", " incident ")]
public InArgument<EntityReference> CaseID { get; set; }
Use: Access the input parameter declared above as,
Guid caseid = CaseID.Get<EntityReference>(executionContext).Id
6. OUTPUT Parameters
CRM 4.0
[CrmOutput("outputSum")]
public CrmMoney Sum
{
get
{
return (CrmMoney)base.GetValue(SumProperty);
}
set
{
base.SetValue(SumProperty , value);
}
}
CRM 2011
[Output("outputSum")]
[Default("23.3")]
public OutArgument<Money> Sum { get; set; }
happy Coding