Monday, November 19, 2012

Sending an Email using CRM 2011

http://rajeevpentyala.wordpress.com/2011/08/03/sending-an-email-using-crm-2011-plug-in/

Wednesday, November 14, 2012

Different Plugin CRM 4 and CRM 2011

1) References
We no longer use the Microsoft.Crm.* DLLs, as the namespace had a complete makeover. MS CRM 2011 introduced a brand new namespace “XRM”, hence the DLLs to use are Microsoft.Xrm.*
Since the changes in MS CRM 2011 SDK are using WCF based services (compared to the web services used by its predecessor), we must reference the below mentioned:
o System.ServiceModel
o System.Runtime.Serialization
A reference to the “Microsoft.IdentityModel” DLL is a must if the plugin is targeted at MS CRM 2011 online version.

2) Executing
Execute method now uses IServiceProvider.

CRM 4.0
CRM 2011
public void Execute(IPluginExecutionContext context)
public void Execute(IServiceProvider serviceProvider)

3) IPluginExecutionContext
Similar to the “Execute” method retrieving the context object inside a plugin also changed:
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
4) CRM Service
In CRM 2011, ICrmService is replaced by IOrganizationService
CRM 4.0
CRM 2011
ICrmService _CS = context.CreateCrmService(true);
IOrganizationServiceFactory factory =
(IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
5) DynamicEntity has been changed to Entity
CRM 4.0
CRM 2011
if ((context.InputParameters.Properties.Contains(“Target”) == true) && (context.InputParameters.Properties["Target"] is DynamicEntity))
{
}
if (context.InputParameters.Contains(“Target”) && context.InputParameters["Target"] is Entity)
{
}
Similarly “Properties” of a CRM entity now have to be accessed using the “Attribute” collection:
entity.Attributes.Contains("new_incidentnumber")

Below given template can be used to create a plugin for the MS CRM 2011

using System;
using System.ServiceModel;
using System.Runtime.Serialization;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Messages;
namespace MyPlugin
{
public class MyPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
 IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
 if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
 Entity entity = (Entity)context.InputParameters["Target"];
 if (entity.LogicalName != "entity logical name”)
 { return; }
try
{
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
//Plugin Code
 }

catch (FaultException ex)
 {
throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
}
}
}
}
}

Queues in MS CRM


There are a lot of misconceptions about queues. They only apply to cases and activities.  While the terminology is the same, assigning a case or activity to a queue is not the same as assigning an entity to a CRM user or team. Programmatically what is being used is a RouteRequest rather than anAssignRequest.
To get a better idea how this works we'll look at database. There are two entities storing queue information, the Queue and the QueueItem. These are not customizable.
Queue – (table) contains all queues
  • There are two queues automatically created for each CRM user. 
    • Assigned
    • In Progress 
  • Any user defined queues that you create are also stored here.
    • example:  My New Public Queue
QueueItem – (link table)  Contains an entry for each entity assigned to a queue.
  • An item can only belong to one Queue at a time,
  • The only entities that can below to a Queue are:
    • Activities ( email, tasks, etc. )
    • Cases

reference : 
http://crmscape.blogspot.com/2008_11_01_archive.html

Monday, November 12, 2012

Assigning value and type mapping between dynamics crm versions


Assigning value and type mapping between dynamics crm versions


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 Dynamics CRM 4.0.
AttributeTypeCodeMicrosoft Dynamics CRM 2011 typeMicrosoft Dynamics CRM 4.0 type
AttributeTypeCode.BigIntlongN/A
AttributeTypeCode.BooleanboolCrmBoolean
AttributeType.CalendarRules 
EntityCollection or CalendarRules[]
DynamicEntity[] or calendarrule[]
AttributeType.CustomerEntityReferenceCustomer
AttributeType.DateTimeSystem.DateTimeCrmDateTime
AttributeType.DecimaldecimalCrmDecimal
AttributeType.DoubledoubleCrmFloat
AttributeType.EntityNamestringAttributes with ObjectTypeCode inDisplayMask
AttributeType.IntegerintCrmNumber
AttributeType.LookupEntityReferenceLookup
AttributeType.ManagedPropertyBooleanManagedPropertyN/A
AttributeType.MemostringSystem.String
AttributeType.MoneyMoneyCrmMoney
AttributeType.OwnerEntityReferenceOwner
AttributeType.PartyListEntityCollection or ActivityParty[]activityparty[] or DynamicEntity []
AttributeType.PicklistOptionSetValuePicklist
AttributeTypeUniqueidentifier(Formerly PrimaryKey)System.GuidKey
AttributeType.StringstringSystem.String
AttributeType.StateOptionSetValue or enumeration generated for the entity stateEntityNameStateInfo
AttributeType.StatusOptionSetValueStatus
AttributeType.UniqueidentifierSystem.GuidUniqueIdentifier
AttributeType.VirtualNot used in records.Not used in records.




refrence : http://community.dynamics.com/product/crm/crmtechnical/b/isvlabs/archive/2011/03/05/assigning-value-and-type-mapping-between-dynamics-crm-versions.aspx

How to get entity instance id in CRM 4.0 plugin for each message type

this post you can get instance id in CRM:

Massage name “Create”:


Guid instanceID = new Guid(context.OutputParameters.Properties["id"].ToString());

Massage name “Update”:

Guid instanceID = (Guid)((Microsoft.Crm.Sdk.Key)((Microsoft.Crm.Sdk.DynamicEntity)context.InputParameters.Properties["Target"]).Properties[context.PrimaryEntityName + "id"]).Value;

Massage name “SetState”:

Guid instanceID = new Guid(context.OutputParameters.Properties["id"].ToString()); 

Massage name “Assign”:

Guid instanceID = vInstanceID = (Guid)((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["Target"]).Id;

Massage name “Delete”:

instanceID = ((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["Target"]).Id;

Massage name “Close”:

Guid instanceID = ((Microsoft.Crm.Sdk.Lookup)((Microsoft.Crm.Sdk.DynamicEntity)context.InputParameters.Properties["IncidentResolution"]).Properties[context.PrimaryEntityName + "id"]).Value;

Massage name “Route”:

Guid instanceID = ((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["Target"]).Id;

Massage name “SetStateDynamicEntity”:

Guid instanceID = ((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["EntityMoniker"]).Id;


reference : http://rami-heleg.blogspot.com/2009/12/how-to-go-get-entity-instance-id-in-crm.html

Upgrading a CRM 4.0 Custom Workflow Activity to CRM 2011

this link is very useful for upgrading but you can't solve any problems. it is very generally for upgrading.

http://blogs.msdn.com/b/crm/archive/2010/11/17/upgrading-a-crm-4-0-custom-workflow-activity-to-crm-2011.aspx

Monday, November 5, 2012

How to re-size columns in CRM 4 + javascript

Hi
i didn't find any way to resiza a column on the internet but i can find a way with javascript  that resize a column.
you can use this function in your class in javascript code  and resize your column , that's it.


//this function set width for a field
//"object" argument is an object that is a field and "width" argument can be percentage or pixel and its type is String

    CommonClass.prototype.SetWidthField = function (object, width) {
        //we ensure that object style doesn't change so we save on "oldStyle"
        var oldStyle = object.style.cssText;

        //concat old style with new attribute (width)
        object.style.cssText = oldStyle + ';' + 'width:' + width + ' !important';
    }


sincerely
S.Amir S.Hosseini