Thursday, October 21, 2010

Mapping MSCRM fields from Opportunity Product to Quote Product

For one of our customer we added some custom attributes in Opportunity product and like to add its mappings to quote product and same with quote product to order product so that Opportunity-Quote-Order process can work as expected and the values of the custom attributes in opportunity product could transfer automatically in Quote product.

Now the Big Question :

MSCRM does not directly list the relationship between a Quote Product and Opportunity Product within the available Customization User Interface.

Answer: a little googling and we got this. A very beautiful and simple Four step process:

STEP 1 –

Run a SQL Query against the MSCRM Database (typically Organization_MSCRM where Organization is the Name for the MSCRM Deployment) to determine the GUID Id of the Relationship between the Quote Product Entity and the Order Product Entity.

SELECT    EntityMapId
FROM EntityMapBase
WHERE TargetEntityName='quotedetail' AND SourceEntityName='opportunityproduct'

STEP 2 – Take the output of this SQL Query and insert this into the following URL:


Where [x] is the URL address of the MSCRM Deployment in question and [y] is the GUID Id output of the SQL Query

STEP 3 – This will present the Relationship Mapping screen for mapping attributes from the Opportunity Product entity to the Quote Product entity.

From here, any number of mappings can be added to define how the Products attached to an Opportunity are mapped across when a Quote is added to the Opportunity. (obviously any changes or additional mappings will need to be published in usual MSCRM fashion)

STEP 4 –  Enjoy

The same steps can also be used for controlling how fields are mapped across from Quotes to Orders in a similar fashion.

SELECT    EntityMapId
FROM EntityMapBase
WHERE TargetEntityName='salesorderdetail' AND SourceEntityName='quotedetail'

And similarly how fields are mapped from Order Products to Invoice Products.

SELECT    EntityMapId
FROM EntityMapBase
WHERE TargetEntityName='invoicedetail' AND SourceEntityName='salesorderdetail'

This is a useful technique when working with any custom fields in a Opportunity-Quote-Order process in MSCRM.

Monday, August 2, 2010

How to add images/HTML to Microsoft CRM E-Mail

The Microsoft CRM e-mail templates are HTML and browser-based. As a result, the following requirements must be met to include a graphic in a template:

  • You must be able to display the graphic/Image in a browser. This means that .gif and .jpg graphic formats work best.
  • The e-mail template is an HTML file. Graphics/Images are not “embedded” or attached; rather, only a link is placed in the file pointing to where the actual graphic/Image is located.
  • The graphic/Image must be on a Web site that the e-mail recipient can access.

To add a graphic to an e-mail template:

  1. On the Microsoft CRM Home page, click Settings, click Template Manager, and then click E-mail Templates.
  2. On the Actions bar, click New E-mail Template.
  3. Select a template type and click OK.
  4. Complete the details of the e-mail template.
  5. Open the Web page (using Internet Explorer) or Web site folder (using Windows Explorer) that contains the graphic. Usually all the graphics for a Web site are located in one folder. Links to the graphics in this folder are then placed in the Web files.
  6. Copy and paste the graphic to your e-mail template. Although the graphic will appear, you have copied and pasted only the link to that graphic.
  7. Save the e-mail template.

Now you have the desired email template that could be utilized in your Marketing Campaigns.

Hats off to the beautiful post By Marcello Tonarelli

Thursday, July 29, 2010

First Look at Microsoft Dynamics CRM 2011 codenamed Microsoft Dynamics CRM 5

At the Microsoft WPC conference there was a session called “Taking the Covers Off of Microsoft Dynamics CRM 5”. will be publicly available as a beta release in September 2010 for both online and on-premises deployments. Key Things from the session are :

  1. Microsoft Dynamics CRM 5 is now branded as Microsoft Dynamics CRM 2011.
  2. The key message for CRM 2011 will be the "Power of Productivity"
  3. Microsoft is expanding the global availability of CRM Online now it Will include 8 additional markets 40 markets, 41 languages at the end of 2010.
  4. CRM 2011 will help you manage both customer AND custom relationships.
  5. You can convert an email to Opportunity directly.
  6. CRM 2011 now provides native Outlook access to CRM data (it isn't just an Iframe to the web client like CRM 4.0), benefits include:
    • You can drag columns to reorder, add/remove, use groups, etc.
    • You can toggle the reading pane settings
    • Drag/drop form sections on a personal basis
  7. CRM 2011 allows you to package your customizations into solutions (instead of one giant munged pile of customizations like CRM 4.0):
    • Solutions consist of more than entities, also includes security roles, reports, dashboards, plug-in assemblies, etc.
    • Developers can work with .NET 4.0 framework
    • Can be managed/unmanaged
  8. "processes" (sometimes referred to as scripts or dialogs). This is a huge new feature that a lot of customers ask for in 4.0.
  9. You can now create custom activity types in CRM 2011. Big-time benefit!
  10. CRM 2011 includes field level security! (yeppie… My Favorite)
  11. CRM 2011 will have multiple forms per entity. Yes!!!!!!!!!!

Have a first look in this hour-long exploration of Microsoft Dynamics CRM 5 and see for yourself what all the excitement is about! We dive deep into the new product, discuss strategies for managing upgrades and explore all the opportunities to make the most of this exciting new release. If you’re a long-time Microsoft Dynamics CRM partner, or a BPOS or SharePoint partner looking to engage in the CRM space, this is a session you won’t want to miss.

Speakers: Andy Bybee, Bryan Nielson, Jason Hunt at digitalwpc

Get Microsoft Silverlight

Monday, July 12, 2010

MSCRM 4 - Remove 'Add Existing xxxxx to this record' button

In our CRM implementation where we created several custom entities. It displayed an 'Add Existing xxxxx to this record' button when it was not required and created a lot of confusion among the users. I tried to remove them and like always instead of reinventing the wheel I binged it and then this come to my rescue and within minutes the needful was done. Thanks Dave and 'Dynamic Methods' for this beautiful post. the code that was posted there is :

HideAssociatedViewButtons('new_business_new_surveys', ['Add existing Survey to this record', 'Add a new Survey to this record']);
HideAssociatedViewButtons('new_account_new_eventinvite', ['Add existing Event Invite to this record']);

function HideAssociatedViewButtons(loadAreaId, buttonTitles){
var navElement = document.getElementById('nav_' + loadAreaId);
if (navElement != null) {
navElement.onclick = function LoadAreaOverride() {
// Call the original CRM method to launch the navigation link and create area iFrame
HideViewButtons(document.getElementById(loadAreaId + 'Frame'), buttonTitles);

function HideViewButtons(Iframe, buttonTitles) {
if (Iframe != null ) {
Iframe.onreadystatechange = function HideTitledButtons() {
if (Iframe.readyState == 'complete') {
var iFrame = frames[];
var liElements = iFrame.document.getElementsByTagName('li');

for (var j = 0; j < buttonTitles.length; j++) {
for (var i = 0; i < liElements.length; i++) {
if (liElements[i].getAttribute('title') == buttonTitles[j]) {
liElements[i].style.display = 'none';

Friday, May 14, 2010

When do asynchronous jobs fail, suspend or retry?


Gonzalo Ruiz wrote an excellent article on When do asynchronous jobs fail, suspend or retry? When the CRM Asynchronous Processing Service gets an error, there are three possible actions it will take depending on the type of error:

  • Fail: Job cannot be resumed.
  • Retry: Job will be paused and retried after a period of time.
  • Suspend: Job will be suspended until it is manually resumed.

The entire error handling mechanism is rather complex but I thought of writing down some general rules that will help understanding what the outcome action will be depending on the error that occurs inside the asynchronous job:


Async job

result action


result action

Error code

An SDK call fails: Infinite loop detected



An SDK call fails: Organization disabled


8004A104 / 8004A107

An SDK call fails: Server is busy



An SDK call fails: Other




SQL exception is thrown



Workflow system is paused




Network error



Record associated with workflow cannot be found




The HTTP response fails with code HttpStatusCode.Unauthorized



The HTTP response fails



Plugin or workflow activity throws an InvalidPluginExecutionException



Anything else



Please note that the table above can be used as a general guide but might not cover all scenarios, some exceptions to these actions might apply and it might go outdated in the future.

Why do workflows have a different behavior than other asynchronous jobs when an SDK call fails?

Because the user might be able to fix the problem and resume the workflow. For example, a workflow step sends an email to an account. If the account has no email address, the workflow will suspend with error message "This message cannot be sent to all selected recipients. The e-mail address for one or more recipients is either blank or not a valid e-mail address".

The user can add the email address to the account and resume the workflow. The reason why other asynchronous jobs fail instead is because while workflows are sometimes manipulated by end users, other asynchronous jobs are more oriented towards the system administrator or customizer.

When the result action is Retry, for how long will the job pause before automatically retrying and how much time is there between retries?

The "PostponeUntil" attribute of the asynchronous operation corresponds to the next time it will be retried. The “PostponeUntil” attribute can be retrieved using the SDK. The amount of time to wait until the next retry is calculated considering some deployment settings and grows exponentially on the number of retries. The calculation uses a complex algorithm but these are some default outputs as a function of the RetryCount (the number of times the operation has been retried before):


Time to wait (seconds)











>= 5


Note that by default, any asynchronous operation retrying 5 or more times will be suspended.

When a job has statusreason "Waiting" and statecode "Suspended", how do I know if it will retry or if it is suspended until it is manually resumed?

You can check the "PostponeUntil" attribute of the asynchronous operation to see the time and date in which it will be automatically resumed. If this value is equal to 9999-12-30 23:59:59 (maximum DateTime value) it means that it is waiting to be manually resumed.

How can I retrieve the “PostponeUntil” attribute of the asynchronous operations?

Because the “PostponeUntil” attribute is not available from the entity form or advanced find, you will need to use the SDK to retrieve this value. The following code sample prints the date and time at which each suspended asynchronous job will resume and the number of times it has been retried.

   1: static void Main(string[] args)

   2: {

   3: CrmAuthenticationToken token = new CrmAuthenticationToken();

   4:     token.AuthenticationType = 0;

   5:     token.OrganizationName = "AdventureWorksCycle";

   6:     CrmService service = new CrmService();

   7:     service.Url = "http://crmserver/mscrmservices/2007/crmservice.asmx";

   8:     service.CrmAuthenticationTokenValue = token;

   9:     service.Credentials = System.Net.CredentialCache.DefaultCredentials;


  11:     QueryByAttribute query = new QueryByAttribute();

  12:     query.Attributes = new string[] { "statecode" };

  13:     query.ColumnSet = new ColumnSet(new string[] { "postponeuntil", "retrycount" });

  14:     query.EntityName = EntityName.asyncoperation.ToString();

  15:     query.Values = new object[] { (int)AsyncOperationState.Suspended };

  16:     BusinessEntityCollection bec = svc.RetrieveMultiple(query);

  17:     foreach (BusinessEntity be in bec.BusinessEntities)

  18:     {

  19:         asyncoperation op = (asyncoperation)be;

  20:         string result = String.Format("Operation id={0} PostponeUntil={1} RetryCount={2}",

  21:              op.asyncoperationid.Value,

  22:              op.postponeuntil.UniversalTime,

  23:              op.retrycount.Value);

  24:         Console.WriteLine(result);

Microsoft Dynamics CRM SDK 4.0.12 Available


Microsoft Dynamics CRM SDK 4.0.12 is now available for download! This update contains some very exciting additions:

Advanced Developer Extensions

Advanced Developer Extensions for Microsoft Dynamics CRM, also referred to as Microsoft xRM, is a new set of tools included in the Microsoft Dynamics CRM SDK that simplifies the development of Internet-enabled applications that interact with Microsoft Dynamics CRM 4.0. It uses well known ADO.NET technologies. This new toolkit makes it easy for you to build an agile, integrated Web solution!

Advanced Developer Extensions for Microsoft Dynamics CRM supports all Microsoft Dynamics CRM deployment models: On-Premises, Internet-facing deployments (IFDs), and Microsoft Dynamics CRM Online. The SDK download contains everything you need to get started: binaries, tools, samples and documentation.

Authentication for Microsoft Dynamics CRM Online

New authentication documentation and sample code for Microsoft Dynamics CRM Online is added in this release that does not require using certificates, making it easier for you to write code for your online solutions.

There are quite a few other updates in this version of the SDK package. Refer to the release history on the first page of the CHM for a complete list.


Microsoft launches the Customer Care Accelerator for Dynamics CRM 4.0

The Customer Care Accelerator (CCA) for Microsoft Dynamics CRM focuses on delivering contact center enabling functionality, such as the ability to create a unified desktop by combining data elements from disparate line of business applications and displaying it in a single user interface. The core Customer Care business scenarios highlighted by this accelerator include the following:
Integrated desktop: Customers can aggregate information from diverse business applications into an integrated desktop providing employees with a 360° view of the customer interactions. Customer service representatives have immediate access to business critical information to serve customers quickly and efficiently, increasing customer satisfaction and loyalty.
Eliminating Duplicate Data Entry: Organizations can streamline business processes by creating desktop automation workflows. Process automation eliminates the need for agents to re-enter the same data in multiple applications. Minimizing duplication helps to reduce human error and ensures a consistent customer service experience.
Computer Telephony Integration (CTI): (This is the feature I am most interested in) Organizations are provided with a consistent framework to connect CTI systems with key line of business applications. CCA provides out of the box CTI integration with the major soft and hard phone providers – many of which already have their native integration offerings to Microsoft Dynamics CRM. Also includes is integration to Bing Maps and the Office Communications server so agents can leverage an Expert on Call by opening a chat window and bring in the contextual information from the customer session into the assisted chat. The Dynamics CRM customer care accelerator also provides session management where an agent can 'park' a customer session and then come back to it.
Activity Reporting: Contact center managers have swift access to agent desktop transaction reporting, helping them to identify process bottlenecks. It Provide visibility into agent activities using out of the box and custom reports. you can download a copy to evaluate and play with it from here.

Friday, April 23, 2010

How to use the Data Enrichment (re-import) feature in Microsoft Dynamics CRM 4.0 (although officially, it doesn’t exist…)

The Data Enrichment feature allows updating existing data by exporting it from Microsoft Dynamics CRM 4.0 to Excel, modify it in externally and then re-import it, updating the existing records with the new data. This feature is very useful in scenarios where mass update is required for existing data or when you need an external party to add data to your existing CRM records.

Unfortunately, this useful feature was removed from the Microsoft Dynamics CRM 4.0 RTM version. I am not sure why, some claim it is potentially harmful and can make a mess of existing data.

The surprising news is that you can still use this non existing feature. How? Here is an example:

In this example scenario, I want to update all my contacts with new data: email address.

  1. Select an existing view or edit a new view using the Advanced Find. Make sure the columns you want to add data to are included
    Select records to export

  2. Export the view data using the ‘Export to dynamic worksheet’ option and save it.
    Select export type
  3. Open the exported file, select all records, go to the Format menu, select Column sub menu and then the Unhide option. A new column should appear, containing the records GUIDs.
    Select all data
    Unhide the GUID column
  4. Rename the GUIDs Column to the name of the exported entity for example ‘Contact’. Move the column to the left of all other columns.
    Move GUID column to the far left
  5. Update the required data. In this example, the email data is added to the existing records.
    Add the new data
  6. Save the Excel file as .csv file.
  7. Use the Import Wizard tool in Microsoft Dynamics CRM 4.0 to import the newly created .csv file. Select ‘none’ for Data Delimiter, ‘Comma (,)’ for field Delimiter. 
    Select file and delimiters in data import wizard
  8. Click next and select the exported entity, ‘Contact’ in this example. You can see the ‘Enrich data by updating records rather than creating new records.’ option available and checked. Select a data map if required and click next
    Notice the checked Enrich data option
  9. Check the ‘Import duplicate records’ option and click next
    Check import duplication records
  10. Complete the import process.
  11. Go to the workplace and open the data import section. Once the data import job is done, open the the job records and see which records were updated. Notice that existing records were updated, no new records were created.
    Go back to the exported view
  12. Finally, refresh the view you started with to see the updated data for the existing records.
    Refresh the view to see the updated records

Although the product Help file still regards this feature as available, I consider this an unsupported feature. Use the above method at your own risk.

Note: A record will not be updated if it has been changed in Microsoft Dynamics CRM 4.0 after it was exported.

Thanks to Yaniv for detailing out these steps. You can view his blog link at