Monday, December 14, 2009

How to Increase the Tab limit in CRM Forms

just browsing the net and i found this beautiful post regarding tab limits in CRM forms , originally posted here

Hats off to the original contributor.

hope its useful for the readers.

By default the max number of tabs allowed in CRM Form is 8.

The max tab limit is defined in JavaScript of formeditor.aspx. This page can be found at the following location “\Microsoft Dynamics CRM\CRMWeb\Tools\FormEditor”.
You can change the count specified in the _iMaxTabs to increase the count as shown in the below screenshot.



Note: This is an unsupported change and it could be overwritten if you install Rollups for CRM.

Thursday, November 26, 2009

Managing the Solution Lifecycle for xRM Applications

The recording of session by Andrew Bybee delivered at PDC-09 is now available. A must watch video. take a look at it here :

Developing xRM Solutions Using Windows Azure

The recording of session by Andrew Bybee delivered at PDC-09 is now available. A must watch video. take a look at it here :

Build a .NET Business Application in 60 Minutes with xRM and SharePoint

The recording of session by Barry Givens, Nikhil Hasija delivered at PDC-09 is now available. A must watch video. take a look at it here :

Friday, November 20, 2009

Top Ten Reasons Why Your CRM Should Be Microsoft Dynamics CRM


1.   Turns Microsoft Office Outlook into the one place where you can manage both customer data and communications.

Microsoft Outlook messaging and collaboration client is already the world’s leading tool for customer communications.  Microsoft Dynamics CRM extends the reach of Microsoft Outlook by turning it into a tool to manage customer information. It puts lead information, marketing pitches, and sales call information into one central location for your sales and marketing staff.

2.   Works tightly with Microsoft Office Excel so businesses can make decisions on the fly.

Microsoft Excel spreadsheet software is a powerful tool for turning data into information that can be analyzed and shared. Microsoft Dynamics CRM features an always-on connection to Excel that enables you to quickly turn customer information into dynamic snapshots or PivotChart dynamic views. These views can help you understand in seconds how a sales increase or company expansion can benefit the business.

3.   Improves operational efficiency through the standardization and streamlining of processes.

The Microsoft Dynamics CRM adaptive workflow engine enables a business to automate business processes in ways that employees can use each day. Microsoft Dynamics CRM can relieve your staff of mundane but vital work. It can automate time-consuming repetitive tasks, warn staff of open customer issues, and automatically send important e-mail messages to customers and partners. So customer requests and orders don’t fall through the cracks.

4.   Works the way your business works with point-and-click system customization.

Microsoft Dynamics CRM can be tailored to work the way your business already works. Microsoft Dynamics CRM forms, relationship links, and customer views can be designed and modified without complicated programming.

5.   Gives the right information to the right people.

Certain employees need certain information. With Microsoft Dynamics CRM, system administrators have the tools to make sure the right information is delivered to the right people—whether they are using Outlook or the Web.

6.   Targets your marketing campaigns so you’re always in touch with the right customers.

Today, it’s more important than ever that customers know about special offers and new services a business offers.  Microsoft Dynamics CRM offers a marketing automation module that simplifies the following tasks: Building customer and lead lists, developing marketing campaigns targeted at specific customers, measuring the results of these campaigns, and developing follow-up marketing efforts.

7.   Simplifies service scheduling to keep customers satisfied.

One of the most challenging aspects of delivering great customer service is ensuring you never let customers down by missing a service call or appointment. Microsoft Dynamics CRM provides a centralized, all-in-one view of all customer service requests and service professional calendars. Dispatchers can quickly and easily match the right service personnel to a particular customer or type of service call.

8.   Integrates with your existing systems to help break down information silos.

Microsoft Dynamics CRM harnesses the power of Web services through the Microsoft .NET Framework. This latest generation of Microsoft technology enables businesses to connect isolated, legacy business systems and applications.

9.   Enhances offline communications so everyone can be productive regardless of location.

Microsoft Dynamics CRM is designed so your staff can be productive both in the office and on the road—even if they aren’t connected to a network. Information can be filtered so that people receive only the information they need such as meeting updates and sales figures.

10.  Builds on the power of SQL Server Reporting Services to create insightful business reports.

The SQL Server Reporting Services engine is a powerful analytical tool for business. The Microsoft Dynamics CRM embedded reporting engine integrates smoothly with Microsoft SQL Server to generate compelling data reports for business decision makers.

Microsoft Dynamics CRM 4.0 Training\Demo Videos


Microsoft Dynamics CRM 4.0 equips business professionals with access to customer information through a full suite of marketing, sales and service solutions within a familiar Microsoft® Office Outlook® interface to ensure rapid user adoption and fast results. These videos will introduce you to Microsoft CRM Online functions and capabilities.

Video: General Overview - Time: 15:00
This video will provide a navigation overview of Microsoft Dynamics CRM 4.0 via the Outlook client and Internet Explorer Web Browser.

Video: Sales Overview - Time: 12:00
This video will show the sales features in Microsoft Dynamics CRM 4.0 from creating a lead that leads to an opportunity that then leads to a quote.

Video: Marketing Overview - Time: 21:04
This video will show the marketing features of Microsoft Dynamics CRM 4.0, including Campaigns, Marketing Lists, Campaign Activities and Responses, and Reporting.

Video: Working with Accounts & Contacts - Time: 05:30
This video will show how to work with Accounts & Contacts within Microsoft Dynamics CRM 4.0

Video: Customer Service Overview - Time: 14:54
This video will provide an overview of the customer service functionality in Microsoft Dynamics CRM 4.0.

Video: Service Scheduling Overview - Time: 13:55
This video will provide an overview of the service scheduling functionality in Microsoft Dynamics CRM 4.0.

Video: Reporting Overview - Time: 15:29
This video will show the reporting capabilities in Microsoft Dynamics CRM

Video: Mail Merge - Time: 08:03
This video will show how to create mail merge templates and create emails and Word labels with mail merge.

Video: Using Advanced Find - Time: 10:02
This video will show you how to use the Advanced Find feature to find and take action on targeted sets of data. It will also show how to create Saved Views (My Views).

Thursday, November 19, 2009

check out the PDC 09 videos

check out the PDC 09 videos here

Tuesday, November 10, 2009

CRM 4.0 delete Organization

some time back I created an organization in our CRM server for a client but after some time we were told to remove the organization. I searched everywhere in the deployment manager but found no option to do the same. The only option I got there was to disable the organization. I scratched my head try almost all the links but of no use, so finally I disabled the organization. few days back i discussed the same with one of my friend Naren about the same he also did the full research in the deployment manager and YESSSSS he found the way. All we need to do is to first disable the organization and then we got the option to re enable it or delete it. the only thing now we need to remember is that this delete operation does not delete the org_MSCRM database , you have to delete the same manually.

Thanks Naren for the help.

I hope someone else too will get benefitted from this post. enjoy…

Thursday, September 10, 2009

CRM developer toolkit v1.0

A new toolkit to make customizations to CRM 4.0 has been released. Download bits from

View All CRM Entities - Displays a listing of CRM entities that are dynamically available from the CRM Explorer within Visual Studio 2008
Create and Update CRM Entities - Allows for creating new entities and updating existing entities from within the CRM Explorer experience
Create a Wrapper Class - Provides the ability to auto-generate wrapper classes for entities, which exposes the CRM entities and their corresponding attributes as classes and properties respectively to enable development of code to interact with the entities
Generate Plug-in Code - Enumerates the available Plug-ins for an entity and generates the code necessary to jumpstart the plug-in development process
Integrate the Build and Deploy Process - Simplifies the process of building and deploying a CRM solution
Deploy Across Multiple Servers - Assists in deployment and maintenance of Windows installer packages across multiple environments
The E2 team would also like to encourage Toolkit users to submit comments, suggestions, or other general thoughts about extending Toolkit functionality to better support the efforts of developers in planning, developing, customizing, and maintaining on-premise deployments of Microsoft Dynamics CRM. To initiate or participate in Toolkit discussions, In Code Gallery, please see visit the Toolkit Discussions tab at

Tuesday, August 25, 2009

Changing Ownership of Accounts changes ownership of others too

When we reassign a CRM Record then by default, Dynamics CRM reassigns all child records too. This behavior has consequences you might not want, such as reassigning paid invoices and other closed transaction records too, or think about a scene where two different sales reps are working on two different opportunities, associated with the same account then if the ownership of account changes the CRM reassigns the ownership of these two Opportunities too to the new owner, not only that the reassignment is done irrespective of the status of the related child record. i.e even the closed sales too goes in account of the new owner.

In short Selecting a different value for the “Owner” field (reassigning of the record) would reassign the account to the newly selected CRM user. Along with a lot of other records, which is the potential problem when historical sales reports are needed.

for quite some time i was thinking about the issue and the possible solution. Today I got a surprise visitor in my outlook (the RSS feed from dynamicscrmtrickbag). much to my surprise Richard Knudson explained the same issue and the solution in his blog.

The solution was quite simple :

Have a look at all of the 1:N relationships the Account entity has with other
Dynamics CRM entities , change the Type of Behavior of the required relationship
from default “Parental” relationship to “Configurable Cascading” and change the
assignment behaviour by changing the "Assign" value to the desired behaviour
(Cascade Active or Cascade None or Cascade User-Owned).

I would recommand the reading of full article here.

Great piece of artwork Richard. Cheers.

Wednesday, July 22, 2009

How to Troubleshoot the Outlook CRM Client

Hello all,

The Outlook Client for CRM is one of the most intriguing features in the Microsoft Dynamics CRM 4.0. Rather than having users ‘go somewhere else’ to use CRM, the Outlook CRM client provides in integration to Outlook — allowing end users easy access to CRM from where they do most of their day to day work.

Due to the sheer number of components the Outlook CRM client leverages, troubleshooting problems related to it could best be described as an adventure.

A great article is posted at the CRM Team Blog recently about how to troubleshoot and isolate common Outlook CRM Client issues. this could be of great help for those experiencing issues. Don’t forget to run that Diagnostic Tool first.

go through it here :

Tuesday, July 21, 2009

Cannot Delete/Publish changes in a Custom/System Entity

Hi all,

for quite some time I was struggling with this issue :

Neither we were able to publish changes to a custom entity nor the system allowing us to delete it. while doing so we get the general popup error from that says "An error has occured." We were able to publish updates to all other entities. Also we could add or delete other custom entities.

Another thing that Custom entities have their own custom icons when you click on them and go into the Form or looking at an attribute. For these entities, there's just a red X. I didn't delete any files but still no icons were displayed while other custom entities that work display the icons just fine.

after enabling the trace we found this in trace log :

[NullReferenceException: Object reference not set to an instance of an object.] at Microsoft.Crm.ObjectModel.OrganizationUIService.LabelLoaderAllLanguages.LoadMetadataLabel(Int32 entityType, String attributeName, ExecutionContext context) at Microsoft.Crm.ObjectModel.OrganizationUIService.LabelLoader.LoadCellLabel(Guid cellObjectId, String cellObjectColumnName, Int32 objectType, String attributeName, ExecutionContext context) at Microsoft.Crm.ObjectModel.OrganizationUIService.InsertFormLabels(IBusinessEntity entity, ILabelLoader labelLoader, ExecutionContext context) at Microsoft.Crm.ObjectModel.OrganizationUIService.RetrieveMultipleWithAllLanguages(EntityExpression entityExpression, ExecutionContext context) at Microsoft.Crm.Metadata.OrganizationUIHelper.RetrieveInProductionHelper(Int32 objectTypeCode, ExecutionContext context) at Microsoft.Crm.Tools.ImportExportPublish.FormXmlHandler.ExportItem(XmlDocument importDocument) at Microsoft.Crm.Tools.ImportExportPublish.ExportHandler.Export(XmlDocument XDoc) at Microsoft.Crm.Tools.ImportExportPublish.ExportHandler.Export(XmlDocument XDoc) at Microsoft.Crm.Tools.ImportExportPublish.RootExportHandler.RunExport(String[] ExportEntities, String[] ExportRoles, String[] ExportWorkflows, ExportMask Mask) at Microsoft.Crm.Tools.ImportExportPublish.ExportXml.RunExport(String xmlArgs, XmlDocument& ExportDoc) at Microsoft.Crm.WebServices.ExportXmlService.ExportCompressed(String entities, String embeddedFileName, ExecutionContext context) [TargetInvocationException: Exception has been thrown by the target of an invocation.] at Microsoft.Crm.Application.Utility.Util.RaiseXMLError(Exception exception) at Microsoft.Crm.Dialogs.ExportCustomizationsPage.ConfigureForm() at Microsoft.Crm.Application.Controls.AppUIPage.OnPreRender(EventArgs e) at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) [HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.] at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.cot_puritech__grid_cmds_dlg_exportcustomizations_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

After a long search i zeroed in to these posts:


In the first post the solution provided by André M Mestre
"This is normally caused by a missing attribute or a missing label:
[NullReferenceException: Object reference not set to an instance of an object.] at Microsoft.Crm.ObjectModel.OrganizationUIService.LabelLoaderAllLanguages.LoadMetadataLabel

So to solve this you need to go directly to your database and check in the XML of the forms and views and the XML of the entity and then find out if all the attributes that you can see in there are still viewable in the CRM UI. If not you should correct the XML and then update the database.
The XML for the Form is in the OrganizationUIBase table and you can also check the XML for the views in the UserQueryBase and in the SavedQueryBase.

This is unsupported by Microsoft but is the only solution I know for this kind of issues.
Also please note that correcting the XML might be tricky sometimes."

with the help of the above mentioned solution I checked the Form XML in OrganizationUIBase table and figured out that there was an atribute in the Form XML that was actually deleted from the entity and after that i exported the entity from our staging server to the production server. I still dont know why the entity attribute was there in the form? and if the attribute was there in the form then why the system allowed me to delete the attribute ?

but anyways after recreating the attribute in the entity everything started working properly. it now allows me to publish the changes and even deleting the entity.

hope this will help someone else too.

Monday, June 15, 2009

Create Custom Workflow Activities for Microsoft Dynamics CRM 4.0

Sometimes there are situations when we need to add our own custom logic in workflow. The answer to it is custom workflow activity in Microsoft Dynamics CRM 4.0.

keeping that in mind I have decided to write a post for the same, but as usual before writing any new post I searched for the same on some of my favourite blogs and then I found a great article on the same on stunnware.

A must read post for all newbies. You can find it here.

happy coding :-)

Thursday, June 11, 2009

Invalid Argument error when importing customization

If you export an entity before it has been published, you will get an 'Invalid Argument' error when importing the entity if it has any relationships.

The reason for this is that the relationship attribute will have no display name, which results in the error. The simplest solution would be to go back to the original deployment, publish the entity, then export again. But, if that's not an option, you can fix the problem within the exported xml as follows:

The invalid relationship xml will look like the following:

The problem is that the displaynames element is blank. This can be changed to something like the following

The languagecode attribute will need to be set to the correct value for your deployment. Many other elements will have this value set in the customizations.xml file

Wednesday, June 10, 2009

"Not have enough privilege to complete Create operation for an Sdk entity" exception while registering a CRM 4.0 plug-in

when you try to deploy new plug-in assembly into CRM 4.0 and instead of successfully deploying you get the strange looking Soap Exception "Not have enough privilege to complete Create operation for an Sdk entity".

Unhandled Exception: System.Web.Services.Protocols.SoapException: Server was unable to process request.

Not have enough privilege to complete Create operation for an Sdk entity.

It looked pretty strange because your user might be having System Administrator role and in CRM it might be having all the rights.

Note: The Active Directory account used to deploy and register new assembly into CRM 4.0 database has to be added into Deployment Administrators group in CRM Deployment Manager.

Here are the steps to accomplish this:

1. Open CRM 4.0 Deployment Manager Console (Start -> All Programs -> Microsoft Dynamics CRM -> Deployment Manager).

2. Go to “Deployment Administrators” node and choose “New Deployment Administrator…” option.

3. Insert appropriate user and confirm selection by clicking “OK” button.

After completing this step, your users will be able to register and deploy the assembly successfully. So, remember about this when you try to deploy plug-ins with user that you added to CRM.
Happy Coding :-)

wish to change the code after plugin is deployed ?

After registering your plugin if you wish to change the code, you might get a build error when building the solution again in Visual Studio:
something like :
Unable to copy file "obj\debug\MyPlugin.dll" to "..\..\..\..\Program Files\Microsoft Dynamics CRM Server\Server\bin\assembly\MyPlugin.dll". the process can not access the file "..\..\..\..\Program Files\Microsoft Dynamics CRM Server\Server\bin\assembly\MyPlugin.dll". because it is being used by another process.
This occurs because Microsoft CRM has a lock on the DLL. In order to release the lock, you have to restart the service that has it locked.

For synchronous plug-ins, the CRM Application Pool within IIS can be recycled, or you can run IISReset.

For asynchronous plug-ins and custom workflow assemblies, you have to restart the Microsoft CRM Asynchronous Processing Service in the Services Control panel Applet.

To recycle the CRM Application Pool from the command line: Click Start, Run, type “cscript c:\windows\system32\iisapp.vbs /a CRMAppPool /r” and press enter.

To restart the Microsoft CRM Asynchronous Processing Service from the command line: Click Start, Run, type “net stop mscrmasyncservice” and press enter. Click start, Run, type “net start mscrmasyncservice” and press enter.

Thursday, May 28, 2009

Share Records programmatically

Few days back our client placed a new requirement that he needs the newly created lead needs to to be shared by all the team mates of the businessunit, and that needs to be done automatically. I thought a workflow on lead creation will do the job. But when I sit on the system and to my surprise found that there is no option in the workflow manager for the same. I started scratching my head and at last decided to write a plugin for the same. Now instead of writing everything from scratch I asked the same to my good old friend (GOOGLE) :-) and i was really surprised to get this post by David Fronk of Dynamic Methods Inc. He explained everything in such detail that ...... it starts looking like a kid's play.

With all credit to his great job the excerpts of the post is :

Most implementations just open things up at the business unit level, or even the global level (depending on the size of the company) and don't even worry about sharing. However, there are times when certain information can be sensitive and necessary to restrict access to. Typically these things can be activities, opportunities, cases, services billed, hours worked, etc.

For instance, suppose sales reps aren't allowed to see support cases but are allowed to see the accounts that they manage. Any good account manager would want to know what support issues their account has been having before engaging on a new business proposal, so obviously the sales rep should get to see the cases related to the account.

All that is required is a couple of plugins at two main points and upon creation of a case and reassignment of an account. Whenever a case is created, get the account manager of the account on the case and share the case with that user. If the account gets reassigned, remove the share from the old account manager and add rights to the new account manager. Now with simple logic you can make data more accessible to those who should see the data without them having to do anything more than their regular job.

One side note, be aware that the more items there are under a parent record the longer the reassignments of records will take. For instance, if I reassign an account with 50 cases that's going to take a lot longer to complete the reassignment than it would if there were 5 cases, or even none. Just keep that in mind as you develop your sharing solution.

Pretty simple, and the SDK has some great examples on how to do this. Look up "AccessRights Enumeration", "GrantAccess Message", and "RevokeAccess Message" in the SDK and you should have everything you need.

Here's a quick example on how to share and give all rights to a user:

SecurityPrincipal principal = new
principal.Type = SecurityPrincipalType.User;
principal.PrincipalId = new
PrincipalAccess access = new
access.Principal = principal;
access.AccessMask = AccessRights.ReadAccess;

TargetOwnedDynamic target = new
target.EntityId = new
target.EntityName = "incident";

GrantAccessRequest readGrant = new
readGrant.PrincipalAccess = access;
readGrant.Target = target;
GrantAccessResponse readGranted = (GrantAccessResponse)crmService.Execute(readGrant);

access.AccessMask = AccessRights.WriteAccess;
readGrant.PrincipalAccess = access;
GrantAccessResponse writeGranted = (GrantAccessResponse)crmService.Execute(readGrant);

access.AccessMask = AccessRights.AppendAccess;
readGrant.PrincipalAccess = access;
GrantAccessResponse appendGranted = (GrantAccessResponse)crmService.Execute(readGrant);

access.AccessMask = AccessRights.AppendToAccess;
readGrant.PrincipalAccess = access;
GrantAccessResponse appendToGranted = (GrantAccessResponse)crmService.Execute(readGrant);

access.AccessMask = AccessRights.AssignAccess;
readGrant.PrincipalAccess = access;
GrantAccessResponse assignGranted = (GrantAccessResponse)crmService.Execute(readGrant);

access.AccessMask = AccessRights.DeleteAccess;
readGrant.PrincipalAccess = access;
GrantAccessResponse deleteGranted = (GrantAccessResponse)crmService.Execute(readGrant);

And here is an example on how to revoke access:

SecurityPrincipal principal = new
principal.Type = SecurityPrincipalType.User;
principal.PrincipalId = new
PrincipalAccess access = new
access.Principal = principal;
access.AccessMask = AccessRights.ReadAccess;

TargetOwnedDynamic target = new
target.EntityId = new
target.EntityName = "incident";
GrantAccessRequest readGrant = new
readGrant.PrincipalAccess = access;
readGrant.Target = target;
GrantAccessResponse readGranted = (GrantAccessResponse)crmService.Execute(readGrant);

Override the tool tip of the field in Dynamics CRM

there are times when you want to give your users more information into what they should enter into a field.

As widely accepted the tooltips are the most commonly used and convenient way to achieve the same.

In Dynamics CRM you could use scripts to override the tool tip of the field.

Here's the code script to override the tool tip of the field in dynamics CRM:

var oPopup = window.createPopup();
var oPopupBody = oPopup.document.body; = 'Tahoma'; = '1px solid black';

function showPopupMessage (Tool_Tip_Text)
oPopupBody.innerHTML = "
oPopupBody.innerHTML += "
" + Tool_Tip_Text +"
var X_Coordinate= -100;
var Y_Coordinate= 20;
var width = 350;
var height = 90;
var documentElement = event.srcElement;, Y_Coordinate, width, height, documentElement);

//Be sure to attach your OnMouseOver event with the field's caption

crmForm.all.new_customfield1_c.attachEvent('onmouseover', showPopupMessage ("custom tooltip for new_customfield1 "));
crmForm.all.new_customfield2_c.attachEvent('onmouseover', showPopupMessage ("custom tooltip for new_customfield2 "));
crmForm.all.new_customfield3_c.attachEvent('onmouseover', showPopupMessage ("custom tooltip for new_customfield3 "));

Now you can hover your mouse over the field labels to see your custom tooltip popup

CRM 4 Certification Practice Tests

Hi all,

Richard recently authored practice test questions for the three core CRM 4 certification exams. he is having LOTS of other articles on the exams and how to prepare for them in the certification category. So if you are thinking of clearing the MB 631 , MB 632 or MB 633 you must visit this place.

you can test your knowledge with these practice test here

i have gone through the tests and it is really great. try your knowledge there and best of luck :-)

How to Convert lead to contact, account and/or opportunity programmatically

Sometime we need to convert a lead to a contact, account and/or opportunity programmatically. to achieve this we have to follow the below mentioned process:

it is a two step process. in the first step we need to disable the lead. This can be done by using the SetStateLeadRequest. In the second step we need to use the InitializeFromRequest and InitializeFromResponse classes. It's the InitializeFromRequest class in which we will need to set the EntityMoniker attribute to the lead which you just disabled in the first step. On the same request we'll need to set the target entityname to the name of the entity we wish to convert the lead into (contact, account or opportunity) and then we'll need to set the TargetFieldType. This would most likely be TargetFieldType.All. Now execute that request and here we go .

code example: in this example we will create a function to convert a lead into account programmatically

// <summary>
// Convert Lead To Account
// </summary>
// <param name="service">CrmService</param>
// <param name="leadID">Guid of the Lead that needs to be converted</param>
// <returns>Guid of ctreated account</returns>
public Guid convertLeadToAccount(CrmService service, Guid leadID)
//step one : qualify the lead
SetStateLeadRequest qualifier = new SetStateLeadRequest();
qualifier.EntityId = leadID;
qualifier.LeadState = LeadState.Qualified;
qualifier.LeadStatus = -1;
//Note: lead is qualified, but not converted to account yet

InitializeFromRequest req = new InitializeFromRequest();
// this is the very thing that does the job.
req.EntityMoniker = new Moniker();
req.EntityMoniker.Id = leadID;
req.EntityMoniker.Name = "lead";
req.TargetEntityName = EntityName.account.ToString();
req.TargetFieldType = TargetFieldType.All;
InitializeFromResponse rps = (InitializeFromResponse)service.Execute(req);
Guid AccountID = service.Create(rps.Entity);
return AccountID;

Monday, May 18, 2009

How to Create a Dynamic IFRAME

Change the Page Displayed in the IFRAME
You may want to change the target of the IFRAME based on considerations such as the data in the form or whether the user is working offline. You can set the target of the IFRAME dynamically.
Note When you change the URL for the IFRAME, parameters are not passed to the new URL automatically. You need to append the querystring parameters to the URL before setting the src property.
The following code example shows you how to set the src for the IFRAME and pass the parameters.

var params = crmForm.all.IFRAME_test.url;
params = params.substr(params.indexOf('?'));
var newTarget = "http://mysite/mypage.aspx";
newTarget = newTarget + params;
crmForm.all.IFRAME_test.src = newTarget ;

Allow Access to Form Data
If you trust the target site of the IFRAME you can disable the security attribute so cross-frame scripting is enabled. This allows the target page to reference or change data in the entity form.

A script in the target of the IFRAME can access objects in the parent. The crmForm cannot be referenced by name because it does not have an ID associated with it, but it is the first form in the forms collection.
For example, to set the value of a variable named AccountName to the name of the Account, use the following code in a page that is the target of an IFRAME in the account form:

var AccountName = parent.document.forms[0];

This value, or any other value in the form, can then be processed by the Web page that is the target of the IFRAME.
The Web page that is the target of the IFRAME can also update the crmForm field values, as shown in the following code example:

parent.document.forms[0] = AccountName;

Note : Scripts in Microsoft Dynamics CRM cannot interact with DHTML elements within the IFRAME. This is a security restriction that is set within Internet Explorer for all IFRAME elements.

Reading field values from a lookup

Here is how the value of a lookup field can be retrieved :

//gives us the name of the lookup field's selected record.

//gives us the GUID of the lookup field's selected record.

Tuesday, April 14, 2009

Filtering lookup data in CRM 4

Its a common need for most of the customers to have the filtered lookup fields on the form instead of the current general lookup fields.

while i was browsing on some of my favourite blogs i found a brilient post regarding the same.

while the solution is non microsoft supported , it works for me.

Kudos to George Doubinski for this post
Filtering lookup data in CRM 4

Happy Hacking

Tuesday, February 10, 2009

How to call javascript functions from a custom menuitem

In the previous post we learned how to add custom menus. Now sometimes we need to call some custom functions for some information processing. So for that we can write a javascript function and call that javascript function from the MenuItem click.

for example: we added a MenuItem "Custom JavaScript function" at our desired entity location and wish to call our custom function Myfunction on MenuItem click
so we need to modify the ISV.config as mentioned below:

<MenuItem JavaScript="Myfunction()">
<Title LCID="1033" Text="Custom JavaScript function" />

Now place your function in the entity onload event and expose the Myfunction function to the page level e.g. this.Myfunction = Myfunction;

function Myfunction()
//Place Your logic Here...

this.Myfunction = Myfunction;

Now when you click on the MenuItem "Custom JavaScript function" the function Myfunction will be called.

Adding Custom Menu items

MSCRM provides liberty to add your own CustomMenu to cater your customized needs.
for that purpose all you need to do is to edit the ISV.config file located at path /_Resources/.
This is an xml file so we can say what you all need to do is to customize this xml to suit your needs and you are done.

To add a custom menu MSCRM provides CustomMenu tag that can be introduced in the ISV.config at the following locations:
  1. The MenuBar element inside the Grid can contain an ActionMenu element and one or more Button elements.
  2. The MenuBar element inside the Root or entity element can contain a CustomMenus element.

Adding Action Menu Links to Grid:

<menuitem title="required link 2" url="" winmode="1">
<button title="Test" tooltip="custom button" url="" winmode="2" icon="/_imgs/ico_18_debug.gif">


Adding Menu Links to Entities:

<entity name="account">
<menu title="Custom Menu">
<menuitem title="my file" url="" validforupdate="1" validforcreate="0" availableoffline="false">

Adding Menu Links to Root

<!-- The main Global Menu Bar located at the top of all root level areas -->
<!-- Custom Menus that appear between the Goto Menu and the Help Menu -->
<Title LCID="1033" Text="ISV" />
<MenuItem Url="">
<Title LCID="1033" Text="New Window" />
<MenuSpacer />
<!-- A horizontal drop down menu spacer -->
<Title LCID="1033" Text="ISV Tests" />
<MenuItem Url="" WinMode="2">
<Title LCID="1033" Text="Modeless Dialog" />
<MenuSpacer />
<MenuItem Url="" WinMode="1">
<Title LCID="1033" Text="Modal Dialog" />
<MenuSpacer />
<MenuItem JavaScript="alert('test');">
<Title LCID="1033" Text="Custom JavaScript" />

Monday, February 2, 2009

Error messages in CRM

Most of us while working on CRM, faces error codes returns by CRM. CRM does give you error messages every now and then. The message is usally in the format of "0x12345678". The numbers do not tell much, but the corresponding error message do help you definitely. These error messages are given in the SDK and on a lot of places on the internet, but there the "0x" has been removed from the error message. Here is the same list as which is listed in the SDK, but now with the included 0x, posted by Ronald in his blog.

Do you wanna get rid of "Do you want to close this window?"

I always got this annoying question whenever i opened CRM untill I found the below mentioned code posted by Ronald Lemmen on his blog post here , but its no more now, cheers to Ronald.
You might get a question everytime you open CRM in Internet Explorer.
The question is:
The webpage you are viewing is trying to close the window.
Do you want to close this window?
yes no
This message does appear in CRM 4.0 only when you are using
Internet Explorer 7.0 and you have enabled the application mode setting. Nevertheless, it is an anoying message which you can get away!To get rid of this
open the default.aspx file which resides in the root of the CRM website.
In this file there are these three lines of code:

var oMe = window.self;
oMe.opener =

Modify the second line of this snippet
and end up with these three lines:

var oMe =

You now will not have the message anymore.
Note:Keep in mind that any update or migration might remove this change, but you should be able to reapply the change easily again.

Metadata Browser

The Metadata Browser is a set of web pages which lets you view an Organization’s Entities, Attributes and Relationships.
You can see a quick overview of the metadata for your organization by using the metadata browser. This live view of the metadata, which shows only published information, is found here:


You can use this to view the definition for all entities and attributes in your organization, both system and custom.
If you click an icon in the Definition column, you will see a view of all the attributes in the selected entity. At the top of this view you can view the ownership type of the entity, its type code, whether it is customizable, and if it is valid for Advanced Find.
For each attribute you can view its type, whether it is valid for create, update, and retrieve operations, and so on.

Retrieving the Web Service Version

The Web service version is needed to support ISV applications that can easily detect and work with multiple versions of Microsoft Dynamics CRM. The RetrieveVersion message provides support for determining the version, or build number, of the Microsoft Dynamics CRM software installed on the server.
Example : The following code retrieves the version of the server software and produces output like this: "4.0.7283.0"

// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

RetrieveVersionRequest versionRequest = new RetrieveVersionRequest();
RetrieveVersionResponse versionResponse = (RetrieveVersionResponse)service.Execute(versionRequest);

CRM Web Services

Microsoft Dynamics CRM 4.0 provides a dynamic Web service interface for applications to use to access and manipulate platform data as well as interact with platform services. These services allow ISVs to write applications using Microsoft Visual Studio or other developer tools by simply referencing the platform Web service. The Web services exposed by the platform are WSI BP 1.1 compliant. This compliance support makes the Web services interoperable with non-Microsoft platforms.
The Microsoft Dynamics CRM SDK includes the following Web services:
1. Discovery Web Service (DiscoveryService.asmx)
2. CRM Web Service (CrmService.asmx)
3. Metadata Web Service (MetadataService.asmx)
The Discovery Web service is a mechanism to find the correct CrmService endpoint for your organization or to obtain a CRM ticket for Internet-facing deployment (IFD) or for Microsoft Dynamics CRM Online.
The CRM Web service provides strongly typed access to all entities in Microsoft Dynamics CRM, including custom entities and attributes. This Web service also allows execution of all supported operations, including those with built-in business logic as well as specialized operations. It provides a valid Web Services Description Language (WSDL) that is dynamically generated on the server to include the latest customizations and provides a single endpoint for your code.
The Metadata Web service provides methods to read and write the metadata for an organization. This includes the definitions for entities, attributes, and relationships.
In Microsoft Visual Studio 2005, you use the Add Web Reference command to point to the Web services. After the Web reference has been added to your project, all of the Web methods and classes in the Web service's namespace are available in your project.
For more information about Web services, see The Microsoft Web Services Developer Center You can also read the article "XML Web Services Basics" here

Custom Entities

A custom entity is a business entity whose schema is created through the customization tools in the Microsoft Dynamics CRM Web application or by using the Metadata Web service. This feature enables you to provide important extensions to support vertical business requirements. It also makes building on the Microsoft Dynamics CRM platform easier, enabling ISVs, for example, to produce solutions that integrate seamlessly with Microsoft Dynamics CRM.
Custom Entity Life Cycle
– The schema is created and an empty form is published.
Update - Schema changes are saved to the metadata but UI changes remain unpublished.
Publish - UI changes are published and are visible in the application.
Delete - Schema changes and the UI is changed immediately, no publish step is needed.
When you create a custom entity using the Web application, you enter the schema name for the entity. This name is used to create the logical name and the filtered view name.

Custom entities also support the following functionality:

You can create forms, views, and reports to expose your new entities in Microsoft Dynamics CRM.
You can publish, export, and import these new entities and their associated forms and views.
You can include these new entities in the dataset that Microsoft Dynamics CRM for Microsoft Office Outlook users can take offline.
You can secure these new entities in the same manner as other Microsoft Dynamics CRM entities.
The security privileges available for organization-owned custom entities are as follows: create, read, write, delete, append, and append to.
The security privileges available for user-owned custom entities are as follows: create, read, write, delete, append, append to, assign, and share.
You can define relationships for custom entities.
Callouts for custom entities function in the same manner as for system entities.
Client-side events function in the same manner as those for system entities.
Custom entities can be extended using the ISV.config file in the same manner as system entities.
The filtered views for custom entities are available to be used in the same manner as for system entities.

Accessing the Server Using the Web Service

Accessing the Server Using the Web Service
Methods are called by first creating an instance of the Web service. In Microsoft Visual Studio 2005, Microsoft IntelliSense support is provided on the Web service methods. To access the server, you may need to specify the URL as shown here for the CrmService.
The following is a simple example accessing the Web service. For a complete set of samples for different authentication scenarios, see Web Service Security and Impersonation.

// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";

CrmService service = new CrmService();
service.Url = "http://<servername>[:<port>]/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

The Web references to the Microsoft Dynamics CRM Web services define a default value for the service's URL property. These default URL values contain the Web service addresses for the Microsoft Dynamics CRM server that was used when you created the Web references. If you need to point your application at a different Microsoft Dynamics CRM server at run time, you must set the CrmService.Url property to the address of the Web services on that server.
Note As a best practice, you can store the URL of the Microsoft Dynamics CRM server in the application configuration file for your custom code.
If you wish to run your code against a Microsoft Dynamics CRM server on a different domain, you cannot use the default network credentials. You must define valid domain credentials for the domain that has Microsoft Dynamics CRM access rights. Alternatively, you can establish a trust between the two domains.

Important You must assign a CrmAuthenticationToken value to the Microsoft Dynamics CRM Web service instance before calling Web service methods. Failure to do so results in an HTTP 401 error when the Web service methods are called.


The GenerateAuthenticationHeader function retrieves a properly formed Microsoft Dynamics CRM authentication header. This authentication header automatically determines the appropriate authentication type to use for each deployment type: on-premise, IFD, or Microsoft Dynamics CRM Online. Note that the SOAP header for IFD does not include information about the CrmTicket because a session-based ticketing system is used. For more information, see Authentication.

Each XMLHttp request requires a <soap:Header>
You can generate this header for your code by using the following function:
Without this function you would need to define a SOAP header in your code like the one here for the on-premise version:

<CrmAuthenticationToken xmlns="">
<AuthenticationType xmlns="">
<OrganizationName xmlns="">
<CallerId xmlns="">

CRM SDK Assemblies

The Microsoft Dynamics CRM SDK includes the following assemblies:
This assembly contains the base classes needed to develop custom workflows and workflow activities. It also contains helper classes which can be used when you develop plug-ins and workflows.
This assembly contains types needed when you develop plug-ins and custom workflows. These include the request/response classes and a set of methods that are used for instantiating CRM types can be found in Microsoft.Crm.SdkTypeProxy.CrmTypes.
This assembly also includes the same set of entity classes, such as account class. However, these are for internal use only. When you work with entity instances, you should use the Microsoft.Crm.Sdk.DynamicEntity class or add the CrmService WSDL to your code and use the entity classes found there.
See Microsoft.Crm.SdkTypeProxy Namespace for reference documentation on this assembly.
This assembly contains methods and types needed for customizing Microsoft Dynamics CRM for Microsoft Office Outlook.
See Microsoft.Crm.Outlook.Sdk Namespace for reference documentation on this assembly.
This assembly contains methods and types needed for developing a custom E-mail Provider component for the Microsoft Dynamics CRM E-mail Router.
See Microsoft.Crm.Tools.Email.Providers Namespace for reference documentation on this assembly.
Both 32-bit and 64-bit versions of these assemblies can be found in the SDK\Bin folder of the SDK download. The download is located at
If you are running in a 32-bit process, use the 32-bit assemblies. If you are running in a 64-bit process, use the 64-bit assemblies.
For synchronous plug-ins, use the version that matches the Microsoft Dynamics CRM server.
For custom workflow activities and asynchronous plug-ins, use the version that matches the Asynchronous service.
For client applications and add-ins, use the version that matches the Web application or Microsoft Dynamics CRM for Outlook.
For Microsoft Dynamics CRM Online, use the version that matches the Web application or Microsoft Dynamics CRM for Outlook.

Saturday, January 31, 2009

How to add lookup field in an entity

There are times when we need to select a value from a set of values.

Now the set of values may be fixed or might not be fixed (that is coming from another table or in other words some dynamic set of values are there)

Now for these two options we have two solutions: Picklist or Lookup

Picklists are mostly used when we have a fixed or defined set of values but for dynamic values or picking values from a table, we can use custom entity and add it as a lookup to our form.

Now to achieve this we just need to create a 1:N relationship in the Table entity to the entity which we want the lookup to be. By Table entity,I mean the table that which we need to display in lookup.

1. Go to : Settings->Customization->Customize entities.

2. Create a new entity for the new table data.

3. Every entity has a primary field. This field gets shown up in the lookup. Name this field appropriately.

4. Publish this entity.

5. Now double click any other entity, where we would want the lookup.

6. In the left navigation pane, we'll find N:1 relationships.Create an N:1 relationship with the entity created in step 2.

7. Now go to forms and views on the same entity. Click on Main Form.

8. Select 'Add fields'.

9. Add the required lookup field.

10. Publish the changes.

11. Populate the entity created in step 2 with data and say cheers as its done.