Monday, March 9, 2009

How to use the Duplicate Detection Feature of CRM

CRM 4.0 provides a facility to detect duplicate records with same attribute value. To enable the duplicate detection you have to create a duplicate rule.

To create duplicate rule GoTo ->Settings->Data Management->Duplicate Detection Rule->New. Then you will get below window.


In above screen shot The fields which are covered with red rectangle are as follows :

1. Name : Name of the rule.
2. Status Reason : Status reason is by default unpublished. When you published this rule then status reason get Published automatically.
3. Base Record Type : In this we choose an entity by which we can find duplicate records.
4. Matching Record Type : In this we choose an entity on which we check the duplicate records.
5. Now we define the attributes on which we want duplicate detection.

Here I select contact in both “Base Record Type” and “Matching Record Type” because I want to compare “First Name” and “Last Name” of contact only.
If you want to check Is there any existing Contact With “First Name” and “Last Name” that you fill in the lead. Then do the following


Select Lead as “Base Record Type” and Contact as “Matching Record Type” and select the attribute of both entities on which you want to duplicate detection.
In this case whenever you want to save a lead then duplicate detection will run if a contact exists with the lead’s “First Name and “Last Name”.

When you create a record then duplicate rule will search for any existing record With “First Name and “Last Name”. If any existing record is found then The following pop up is generated.



Now if you want to save the duplicated record then click on Save Record if not then click on Cancel.

Note : Please Start Asynchronous Service before running the duplicate detection.

CRM Live Login LogonManager error

We were working on making one of add-ons CRM Live compatible. During development all worked well. However on a test environment it was unable to instantiate the logon manager object.


After checking around a lot and playing around with a lot of settings on the server we found that the issue was with the AppPool under which the website was being run. The identity of the AppPool was Network Service as usual, we changed that to run under Local System and voila it worked!!!

So the prerequisites to get the application designed for CRM Live working would be:


1. have the “msidcrl40.dll (IDCRL Dynamic Link Library)” present in your System32 folder.
2. Make sure that the website is running under an AppPool identity that has permissions to access the msidcrl.dll

This solved our problem and we were able to login to the Live account of CRM from aspx page.


We are not sure about the security and stability aspect of this and we just posted this as it happened to solve our problem immediately. More in this later as and when we research and get feedback.

Microsoft Office Accounting Integration Link with Microsoft Dynamics CRM now supports Dynamics CRM version 4.0 Partner Hosted deployment

Our Integration Module for Office Accounting and Dynamics CRM now supports the Partner hosted deployment as well.

In the Partner hosted model, the Integration Module shall be setup locally on users local machine and does not require any files to be hosted on the server.

For more information on the Intergration module visit http://www.inogic.com/integration_off_accounting.htm

Thursday, March 5, 2009

How to Login to various CRM deployments

CRM supports various Deployment methods and unfortunately for the developers the method to connect to each of these differs. So here are the login functions for each of the Deployment methods supported by Dynamics CRM.

On Premise CRM connection:

On premise uses AD for authentication.

CrmService service = new CrmService();

service.Url = "http://" + servername + "/mscrmservices/2007/crmservice.asmx";

service.CrmAuthenticationTokenValue.OrganizationName = "orgname";

service.CrmAuthenticationTokenValue.AuthenticationType = 0;

service.Credentials = new System.Net.NetworkCredential("username", "Password", "DomainName");

OR

crmService.Credentials = System.Net.CredentialCache.DefaultCredentials;


Live CRM connection:

CRM Live uses Passport authentication. It requires a reference to the Idcrlwrapper be added. The Idcrlwrapper is available along with the SDK as helper files.

Make sure you have copied the msidcrl40.dll to the system32 folder before you try to run this code.

CrmDiscoveryService discoveryService = new CrmDiscoveryService();
discoveryService.Url = "https://dev.crm.dynamics.com/MSCRMServices/2007/Passport/CrmDiscoveryService.asmx";

RetrievePolicyRequest policyRequest = new RetrievePolicyRequest();

RetrievePolicyResponse policyResponse = (RetrievePolicyResponse)discoveryService.Execute(policyRequest);

// Retrieve a Windows Live ticket from the Live
service.LogonManager lm = new LogonManager();

string passportTicket = lm.Logon("LiveWindowsUserId", "password", "crm.dynamics.com", policyResponse.Policy, "Production");

RetrieveCrmTicketRequest crmTicketRequest = new RetrieveCrmTicketRequest();

crmTicketRequest.OrganizationName = "OrganizationName";

crmTicketRequest.PassportTicket = passportTicket;

RetrieveCrmTicketResponse crmTicketResponse = (RetrieveCrmTicketResponse)discoveryService.Execute(crmTicketRequest);

CrmAuthenticationToken token = new CrmAuthenticationToken();

token.AuthenticationType = 1;

token.CrmTicket = crmTicketResponse.CrmTicket;

token.OrganizationName = crmTicketResponse.OrganizationDetail.OrganizationName;

Now, once you have the token assign it to the crmservice object as we do in on premise.

Hosted CRM connection:

This uses SPLA authentication. You need to use the userid and password provided to you by your hosting provider. You would also need to get the discovery URL from them.

From the discovery service URL you can retrieve the list of organizations.

RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();

orgRequest.UserId = username;

orgRequest.Password = password;

RetrieveOrganizationsResponse orgResponse = (RetrieveOrganizationsResponse)disco.Execute(orgRequest);

//Find the desired organization with which you want to connect.
//Retrieve the ticket.

RetrieveCrmTicketRequest ticketRequest = new RetrieveCrmTicketRequest();

ticketRequest.OrganizationName = organization;

ticketRequest.UserId = username;

ticketRequest.Password = password;

RetrieveCrmTicketResponse ticketResponse = (RetrieveCrmTicketResponse)disco.Execute(ticketRequest);

//Create the CrmService Web service proxy.
CrmAuthenticationToken sdktoken = new CrmAuthenticationToken();

sdktoken.AuthenticationType = 2;

sdktoken.OrganizationName = organization;

sdktoken.CrmTicket = ticketResponse.CrmTicket;

Now, once you have the token assign it to the crmservice object as we do in on premise.

Monday, March 2, 2009

How to add the CrmService Web Reference for non-default CRM Organization or for CRM Live environment.

As a beginner in programming for Dynamics CRM but with knowledge of .NET, you would definitely like to first be able to add the CrmService Web Services Description Language (WSDL) to your Visual Studio project by using the URL of your Microsoft Dynamics CRM server.

CRM 4 additionally supports multi-tenancy and hence in the Enterprise edition of CRM you can have more than one Organization setup on your CRM server. While you could use the usual steps for adding a web-reference for the default Organization, if you need to pick up the customizations for a non-default organization you would need to follow the below steps.

These same steps need to be used when adding a reference for the CRM Live environment.

To obtain the Web reference for Microsoft Dynamics CRM Live you must first save a copy of the Web Services Description Language (WSDL) file to your development computer.

1. Open a Web browser and enter the URL for Microsoft Dynamics CRM Live. For example: https://demo.crm.dynamics.com/

2. Sign in using your Windows Live ID account.

3. In the Navigation pane, click Settings.

4. In the Settings pane, click Customization.

5. In the Customization area, click Download Web Service description files. 6. Click Download CrmService.asmx description (WSDL).

7. When the Web browser opens with the WSDL, save it as an XML file to the SDK\Bin folder or to your Visual Studio project folder. The procedure for saving the file will be different depending on the Web browser you are using. Also, the WSDL XML file can be saved to any convenient local location.

8. Open your Visual C# or Visual Basic .NET project in Microsoft Visual Studio. 9. In the Solution Explorer window, right-click your project name and choose Add Web Reference.

. In the Add Web Reference wizard, type the URL for the CrmService WSDL XML file that you previously downloaded into the URL box, and then click Go. For example:

C:\\CrmServiceWsdl.xml

11. When the CrmService Web service is found, change the text in the Web reference name box to Crmsdk and then click Add Reference.

The Microsoft Dynamics CRM Live Web service is now added to your project. In your source code you can refer to the classes available in this SDK.

Optionally, CRM SDK provides dll’s (Microsoft.Crm.Sdk and Microsoft.Crm.SdkTypeProxy) which can also be used for login and creating CRM service object.These assemblies contains types needed when you develop plug-ins and custom workflows. These assembly also includes the same set of entity classes, such as account class.

However, these are are template classes of default CRM install and the customizations of your organization cannot be found using this as can be through adding web reference of that organization as explained above. When working with entity instances, you should use the Microsoft.Crm.Sdk.DynamicEntity class. When you are using Dynamics Entity class it is possible to refer to any custom entity or custom attribute by setting the appropriate name to the Entity or Property.