Friday, December 30, 2011

Step by step tutorial to add an entity URL to an email in a workflow

Rollup 5 introduced some new features in CRM2011. One of them is to add  an entity URL to an email in workflow. Before rollup 5, it used to be a  complicated process.We don't need to create custom workflow assemblies to this any more.. Still, there are a lot of people asking the same question “How to add entity URLs to emails in workflows” in CRM Forums.
Here is the step by step tutorial to add an entity URL to an email in a workflow.
1.    Start a new workflow.
2.    To send an email. Click on “Add Step” and choose “Send Email”. It will open up a following screen.pic 
3.    Add the information as required and to add the hyperlink, click on hyperlink icon shown in red circle in the above screen shot. It will open up a following screen.
4.    In “Text to display”. Enter the text to you would want to display. I am displaying the full name of the contact. It can be any string.
5.    Select the “URL” text box . When you look through the available fields. You can see a new option “Record URL (Dynamic)”. Click on that and press Ok.  The email will look like following screen.pic3  6.    Press save and close. Publish the workflow and you are good to go.

Monday, December 26, 2011

CRM2011 Subgrids and JavaScript

I have been thinking of bloging about this topic from last 6 months. I wanted to get an aggregate of numeric/money field in the grid. It is very easy to do, if subgrid contains only one page. But How would you get the aggregate if subgrid has more than 1 pages.

I posted this question on the forums and I never get an answer. I still don't have a solution for this problem.

The following sample code displaying the message box with the aggregate of “Estimated Revenue” field  of the opportunity.ce
function subGridOnload() 
 var grid = Xrm.Page.ui.controls.get('Opps')._control;
 var sum =0.00;
 //if  (grid.readyState!="complete") 
 // delay one second and try again. 
 //setTimeout(subGridOnload, 1000); 

 if  (grid.get_innerControl()==null)
  setTimeout(subGridOnload, 1000); 
 else if (grid.get_innerControl()"Loading")!= -1)
  setTimeout(subGridOnload, 1000); 

 var ids = grid.get_innerControl().get_allRecordIds(); 
 var cellValue;
 for(i = 0; i < ids.length; i++) 
     if (grid.get_innerControl().getCellValue('estimatedvalue', ids[i]) !="")
       cellValue = grid.get_innerControl().getCellValue('estimatedvalue', ids[i]); 
       cellValue = cellValue.substring(2); 
       cellValue = parseFloat(cellValue);  
       sum = sum + cellValue;
 }//end for   
I also noticed that  grid.readyState!="complete" does not work all the time.  It happens when the control is already loaded but the grid is still retrieving the data. So I changed the code to check if the records are already loaded.
See you guys……

Monday, December 19, 2011

Updating custom fields on synced outlook contacts in crm2011

CRM2011 does not support synching custom fields between CRM2011 and synced Outlook Contacts.
You can’t even select the fields to sync between CRM and Outlook. The add-in will update the custom fields between synced Outlook contacts with CRM2011.

Software Requirements:

This solution is tested on windows 7 and outlook 2010 only.

Solution components:

The solution consists of 2 components.
  • (CRM2011 Managed solution)
  • (Outlook Addin)

1. :

Download the file and import the solution. The solution creates a custom entity called “syncmapping”. The entity contains two main fields “CRM Field” and “Outlook Field”. The entity will map the fields needed to be updated between CRM2011 Contacts and Outlook Contacts. Before you add any data into the entity, go to the default solution and customize the entity to display in workplace or settings area.

For e.g. In above screen “accountrolecode” (Display Name Role) field in contact entity will update the User1 field or “User Field 1” in Outlook. clip_image004
You can choose multiple fields to update/synced Outlook Contacts as shown in the screen shot below

Note: The display name in both in Outlook and CRM2011 are different than the names used in the code. We need the “Name” field of the CRM2011. To get the proper name of the Outlook field please follow this link
For e.g. The name of “User Field 1” field is User1. “User Field 1” is just a display name. If the field does not exist in Outlook, the solution will create a new user defined field in Outlook.


Extract the file and run the SetupUpdateContact exe. It will add a custom tab to the ribbon as shown in the following screen shot.

When the user clicks on “Update Contact”, it will display a following dialog. Enter all the values and press Update.

The above screen shot displays the values for CRM Online.

The above screen shot displays the values for on-premise CRM Deployment.
At the end of the process, the system will display a following message

This solution updates text fields in outlook only. If you pick an optionset from CRM2011, the solution will get the text value of the field and update the field in Outlook.
The solution uses the update method to update the individual contacts. The solution does not have any automatic or scheduled syncing mechanism.
This solution is smart enough to update the contacts for the selected organization. If you are synced contacts from different organization. The system will update the contacts of the organization selected in a addin dialog.


  • Setup the sync fields in syncmapping entity before pressing the update button
  • Please sync your outlook contacts before trying this solution.
Download this solution.