Monday, July 4, 2011

Microsoft Dynamics CRM 4.0 Whitepapers

Here is a list of some beautiful whitepapers for CRM developers, it always worked as a good reference to me. so thought of sharing it with others too.

you can use them for a reference point or for knowledge building or to understand the product better.

Whitepaper Download

This white paper, details the security model leveraged by Microsoft Dynamics CRM 4.0, including information on the authentication mechanisms that, depending on the deployment model, support Microsoft Dynamics CRM. In addition, the document provides details about how access to Microsoft Dynamics CRM 4.0 system resources by users and external systems can be controlled and restricted.

The Microsoft Dynamics CRM Security Model

This white paper,provides selected aspects of the conceptual application of the security model in Microsoft Dynamics CRM. While Microsoft Dynamics CRM does not provide for true field-level security, there are a number of options available for using supported custom logic to control of access to data at a more granular level than provided out of the box. This document discusses some of the key options and constraints available for implementing this type of solution.

Field-level Security in Microsoft Dynamics CRM: Options and Constraints

Many data centers include firewalls between the end-users and the servers and other integrated systems that support an implementation of Microsoft Dynamics CRM 4.0. This document provides guidance on the connectivity requirements between Microsoft Dynamics CRM 4.0 and other systems to assist readers with proper firewall configuration in customer environments.

Connectivity and Firewall Port Requirements in On-Premise Deployments

Both the online and offline versions of the CRM Outlook Client support synchronizing CRM contacts and CRM activities to Outlook folders, or Outlook synchronization. This document describes the client synchronization process for Microsoft Dynamics CRM 4.0.

Outlook Synchronization in Microsoft Dynamics CRM 4.0

Using multiple instances of Dynamics CRM may be preferable in a number of scenarios. This release includes two documents, a white paper and a build guide, focused on sharing data across multiple CRM organizations. The white paper provides an overview of the levels of integration available for sharing data across multiple Dynamics CRM organizations, together with details about the techniques that are used for integration at the Application and Data levels, which include Web Services, Web Services-based solutions, Filtered Views, and SQL Server Replication.

Sharing Data across Microsoft Dynamics CRM Deploymentsc

Microsoft Dynamics CRM supports a wide range of business applications with the essentials required for building, delivering, and maintaining these applications in a multi-tenant SaaS environment. In this white paper we explore how, with Microsoft Dynamics CRM, an ISV can quickly build, deploy, and manage line-of-business applications.

Developing ISV Applications using Microsoft Dynamics CRM 4.0

This white paper provides techniques, considerations, and best practices for optimizing and maintaining the performance of Microsoft Dynamics CRM 4.0 implementations.

Optimizing and Maintaining Microsoft Dynamics CRM 4.0

These Microsoft Office Visio diagrams show the logical database structure for Microsoft CRM 4.0.

These diagrams were generated using the Metadata Diagram sample code included in the Microsoft Dynamics CRM 4.0 SDK download.

Microsoft Dynamics CRM 4.0 Logical Database Diagrams

Tuesday, June 7, 2011

How To Recreate Users in Microsoft Dynamics CRM

Situation:

One of my teammate recently moved a CRM organization from one server to another server (database as well as the application server), don’t know what went wrong but after that one user complains that he can’t login into the system, when inspected we found that there are two records for the same user now exists in the CRM one disabled and one enabled also no entry of this user was there in MSCRM_CONFIG database.  Still in dark why and how it happens? but in order to let the user in the CRM we need to recreate the user in the CRM.

Resolution:

Now all we need is  to delete this user and recreate it in CRM, BUT BUT BUT…….

There is no supported option of deleting Users from CRM is available , at most you can disable them, but sometimes we found ourselves in a situation when we need to recreate the user in CRM as mentioned above.

we also need to remember that the CRM users are created from AD user accounts so the CRM will not allow you to create a new account even when one account is already disabled.

So what can we do:

The option with us is recreate a User record by changing the credentials of a user record and create a new record for the existing user.

we can do so by following the steps as mentioned below:

Step 1: navigate and open the desired User record in CRM.

Step 2: Change the user credentials in the Domain Logon Name field to and AD use record that is not already a CRM User and save the record.

Step 3: Since this record is not required in CRM at all so disable this record.

Step 4: Create the desired user record.

Step 5: Reassign the records of the disabled user to this newly recreated record.

Wednesday, April 27, 2011

Pre and Post Entity Images

Very Often I found during code reviews the most common mistakes new programmers commit during plugin development in CRM is usage of images at wrong places. so I thought of writing the same here, may be it helps someone.

first we should understand what are 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.

before using the images we should know when they are 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.

Hope it is helpful.

Happy Coding. Smile

Saturday, April 16, 2011

Microsoft Dynamics CRM 2011 – Visual Studio Plugin / Workflow Activity Templates

Just downloaded and checked the great artwork of pogo69. really helpful and saved a lot of time as you don’t have to write everything from scratch now.

checkout the awesome Visual Studio 2010 templates for Plugin and Workflow activity development for CRM 2011 created by him.

Capture

 

check these out at his blog:
http://pogo69.wordpress.com/2011/04/15/crm-2011-visual-studio-plugin-templates

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 Smile

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.
Other Type Changes
Old Type New Type
CrmAttributeType Class (MetadataService) Microsoft.Xrm.Sdk.Metadata.AttributeTypeCode
Moniker Class (CrmService) Microsoft.Xrm.Sdk.EntityReference
SecurityPrincipal Class (CrmService) Microsoft.Xrm.Sdk.EntityReference
Happy Coding Smile

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.

1

Happy Coding Smile

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 Smile

Thursday, February 3, 2011

The Underlying connection was closed: Unable to connect to the remote server

I was working on a program to import thousands of records in CRM when this issue first appears in front of me.  

This is typically seen in scenarios with Microsoft CRM when the server is under high user load or more typically when it is under high load from a Bulk import or a Microsoft CRM SDK application that is importing thousands of records into the application.  

what I was doing :The same user and CRM Service was re-used for all calls after successfully working for some time it stops and this error appears “The Underlying connection was closed: Unable to connect to the remote server” this error is a problem due to running out of TCP ports. You can minimize or eliminate this problem by setting the following registry keys on the Microsoft CRM Server(s).  

Note that these are both REGDWORD Keys and the values should be set as decimal values.

HKLM\Software\CurrentControlSet\Services\TCPIP\Parameters

Create a new REGDWORD value named MaxUserPort with a value of 65534.  

Also create a new REGDWORD value named TcpTimedWaitDelay with a value of 30.

What this means is that we now have a total of 65534 TCP ports available and that they will recycle for use again after 30 seconds. This compares to the default of 5000 ports and a TcpTimedWaitDelay default of 240 (4 min).

enjoy :-)

Tuesday, January 18, 2011

How to change status of the dynamic entity?

to change status of the dynamic entity follow these steps:

   1:  //Create a request object


   2:  SetStateDynamicEntityRequest stateRequest = new SetStateDynamicEntityRequest();


   3:  //Use string and not integer value for state. (For Lead use "Qualified" and not 2)


   4:  stateRequest.State = newState;


   5:  stateRequest.Status = newStatus;


   6:   


   7:  //Create an instance of the entity


   8:  Moniker m = new Moniker();


   9:  m.Id = entityId;


  10:  m.Name = myDynamicEntity.Name;


  11:   


  12:  //Set the state. Well... set the entity.


  13:  stateRequest.Entity = m;


  14:   


  15:  //Send the request


  16:  SetStateDynamicEntityResponse res = (SetStateDynamicEntityResponse)_crmService.Execute(stateRequest);


How to get rid of the CRM 4.0 “new_” prefix

Today one of my junior colleague asked me “Whenever I'm creating a custom entity in CRM, the type is prefixed with "new_". So are any attributes. How can this be modified/removed?”

although it’s quite simple but I thought many more minds might be thinking the same thing around the globe so I have decided to place it  here.

“new_” is the default prefix for custom entities and attributes.

To change it:

  1. Log into the web interface with an administrator account
  2. Select: Settings -> Administration -> System Settings
  3. Select the Customization tab
  4. Change the Prefix value to your desired one.

Happy Coding :-)

Wednesday, January 5, 2011

Don't upgrade to Rollup12 if you use push email

 

from Michael Dawson’s linkedin group post we got the info and got the solution too in our environment , so decided to share if someone too facing this issue. thanks Michael for sharing :-)

“We recently upgraded and have been hit with quite a major issue, when an appointment is synchronized from CRM to your Outlook Calendar, Exchange freaks out when trying to send it to your Smartphone device. You get inundated with the following message:
Synchronization with your SmartPhone failed for 1 items.
The following items couldn't be sent to your mobile phone. They haven't been deleted. You should be able to access them using either Outlook or Outlook Web App.
Item Folder: Calendar
Item Type: IPM.Appointment
Item Created: 21/09/2010 16:23:34
Item Subject: 1723 MDTEST
We have called Microsoft Product Support and this is a known issue that is being researched hopefully for inclusion in Rollup13. I have been advised to uninstall Rollup12 if I want to resolve the issue and go back to Rollup11.”