CRM like scroll bars in HTML web resource or custom page

August 6, 2012 1 comment

When we show HTML web resource or custom aspx pages as part of CRM we may need to show the same styles for the custom pages. Here is the style script to show CRM like scroll bars as part of HTML web resource or aspx pages

<STYLE type="text/css">
    .TA {
scrollbar-base-color: #E9EDF1;
scrollbar-arrow-color: #3b3b3b;
scrollbar-3dlight-color: #A5ACB5;
scrollbar-darkshadow-color: #A5ACB5;
scrollbar-face-color: #E9EDF1;
scrollbar-highlight-color: #E9EDF1;
scrollbar-shadow-color: #E9EDF1;
scrollbar-track-color: # E3E8ED;

}  </STYLE>
<body class='TA'>


Hope this helps 🙂


Signature in Emails using Personal Email Templates

Just like in Outlook users are interested in using Signature facility when creating the Emails in CRM. To get this we can make use of Personal Email templates available.

Personal Email templates will be available for all the users and the one which is created by one user can not be accessed by others unless it is marked for Organization level access.

Here is the way,

  • Go to File–>Options–>Email Templates
  • Select New
  • Select Global as Template Type in the pop up
  • Enter Title as <<User Name Signature>>
  • Enter Subject, As this is a required field we need to give some value here. But When you use the template you can select Not to override the existing subject line
  • Have your signature as part of Body
  • Save and Close

Use Signature Email Tempalte

  • Create an Email activity
  • You can click on Insert template and select the template created above
  • If you first enter the email details like Subject and Body, System will give a confirm box to replace the subject line with the templates subject. Here you can select Cancel to continue with the existing subject line

Hope this small tip helps somebody 🙂

Resolving Duplicate Lookup References in Import Process

Normally when we import records which has a related entity, import process will resolve the lookup reference if it finds single record in the parent entity otherwise, it will stop processing the record and ends in fail.

Ex: When we are importing a Contact (Contact1) with Parent Account (Account1) and system has two accounts with same name then Import process gives error when processing Contact1

To resolve these types of records we need to make a small tweak before submitting the import job. Here we go

Click on Edit in the mapping dialog

Go to Parent Account field in the list of mappings and click on Lookup

Set the unique field as the reference

Now in the import file add the data as Account Number for Parent Account field.

Hope this helps 🙂

Default Calendar View in CRM 2011

Default Calendar view for all users is set to show Day. But users can change this view to show Week or Month from Personal Options window.

Default view


Change settings in Personal Options. File->Options->Activities Tab->Default Calendar View


Month View


Hope this helps

Custom Entity Calendar in CRM 2011

April 24, 2012 6 comments

Calendar view in CRM gives information about Appointments, Service Activities. But there is a restriction to show custom entity unless we create an appointment for that.

In recent past I was working on a requirement to show calendar view for a custom entity, first we thought of creating appointment on creation of the record. But this is messing up with the existing appointments. We have different entities to show in calendar. So we thought to go by a custom web page as an IFrame.

Extend ASP.NET Calendar Control

What I did was I have extended ASP.NET calendar control to override DayRender event to use its capability to show the data in it. Then I used that control to show the custom entity data. Apart from overriding the DayRender event I have added few properties to get the custom data to calendar. Below is code snippet sample

DayRender Event – Code Snippet

protected void EventCalendarDayRender(object sender, DayRenderEventArgs e)
CalendarDay d = ((DayRenderEventArgs)e).Day;
TableCell c = ((DayRenderEventArgs)e).Cell;
if (this.EventSource == null)
DataTable dt = this.EventSource;
foreach (DataRow dr in dt.Rows)
{if (EventStartDateColumnName == string.Empty)
throw new ApplicationException("Must set Calendar's EventStartDateColumnName property when EventSource is specified");
if (EventEndDateColumnName == string.Empty)
throw new ApplicationException("Must set Calendar's EventEndDateColumnName property when EventSource is specified");
if (EventHeaderColumnName== string.Empty)
throw new ApplicationException("Must set Calendar's EventHeaderColumnName property when EventSource is specified");
if (!d.IsOtherMonth
&& d.Date >= Convert.ToDateTime(dr[this.EventStartDateColumnName]).Date
&& d.Date <= Convert.ToDateTime(dr[this.EventEndDateColumnName]).Date)
System.Web.UI.WebControls.Label lbl = new System.Web.UI.WebControls.Label();
// Show the Event Text
lbl.Text = "<BR />" + dr[EventHeaderColumnName].ToString();
// Set the Tool Tip
if (this.ShowDescriptionAsToolTip && this.EventDescriptionColumnName != string.Empty)
lbl.ToolTip = dr[EventDescriptionColumnName].ToString();
// Set the Back Color of the Label
if (EventBackColorName != null && dr[EventBackColorName] != null && dr[EventBackColorName] != "")
lbl.BackColor = Color.FromName(dr[EventBackColorName].ToString());
// Set the Fore Color
if (EventForeColorName != null && dr[EventForeColorName] != null && dr[EventForeColorName] != "")
lbl.ForeColor = Color.FromName(dr[EventForeColorName].ToString());

Web Page to show Custom Calendar

 Now I refer to custom calendar control on my aspx page. We need to pass custom properties values to show calendar.

Register Custom Control on Page

<%@ Register TagPrefix="EXXRM" 
Assembly="ExtendedCalendar" %>

Add Calendar Control on Page

<EXXRM:ExtCalendar ID="CCGlobalCalendar" runat="server" BackColor="White"          BorderWidth="2px" Font-Names="Verdana" Font-Size="8pt" ForeColor="#003399" Height="400px"         Width="80%" FirstDayOfWeek="Monday" NextMonthText="Next &gt;" PrevMonthText="&lt; Prev"         ShowDescriptionAsToolTip="True" EventDateColumnName="" EventDescriptionColumnName=""         EventHeaderColumnName="" CellPadding="2" DayNameFormat="Full"          EventBackColorName="" EventEndDateColumnName="" EventForeColorName=""          EventStartDateColumnName="">         <NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />         <OtherMonthDayStyle ForeColor="#999999" BackColor="Silver"/>         <SelectedDayStyle BackColor="#E6EDF7" Font-Bold="True" ForeColor="#CCFF99" />         <SelectorStyle BorderColor="#E6EDF7" BorderStyle="Solid" BackColor="#99CCCC"              ForeColor="#336666" />         <DayStyle HorizontalAlign="Left" VerticalAlign="Top" Wrap="True" BorderColor="Silver" BorderWidth="1px" BorderStyle="Solid"/>         <DayHeaderStyle BorderWidth="1px" Font-Bold="True" Font-Size="8pt"              BackColor="#A5BFE1" ForeColor="#336666" Height="1px" />         <TitleStyle BackColor="SteelBlue" BorderColor="#3366CC" BorderWidth="1px" Font-Bold="True"             Font-Size="10pt" ForeColor="White" HorizontalAlign="Center"              VerticalAlign="Middle" Height="25px" />         <TodayDayStyle BackColor="#FFDC6D" ForeColor="White" />         <WeekendDayStyle BackColor="AliceBlue" />     </EXXRM:ExtCalendar>

Now we need to bind data to this control. For this blog post I am using defined Fetch XML but based on requirement we can generate EntityCollection. Here are the steps to bind data

Get the records –> Loop through the records to set the properties –> Create DataTable with entity data –> Bind data table to calendar

 Make sure to pass the required properties from data table.

Code to bind data to Calendar Control

string fetchXML = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='contact'>
<attribute name='fullname' /><attribute name='contactid' /><attribute name='modifiedon' />
<attribute name='createdon' />
<order attribute='fullname' descending='false' />
FetchExpression Query = new FetchExpression(fetchXML);
EntityCollection listEntities = GetService().RetrieveMultiple(Query);
DataTable dt = new DataTable();
dt.Columns.Add("Id", Type.GetType("System.Int32"));
dt.Columns.Add("EventStartDate", Type.GetType("System.DateTime"));
dt.Columns.Add("EventEndDate", Type.GetType("System.DateTime"));
dt.Columns.Add("EventHeader", Type.GetType("System.String"));
dt.Columns.Add("EventDescription", Type.GetType("System.String"));
dt.Columns.Add("EventForeColor", Type.GetType("System.String"));dt.Columns.Add("EventBackColor", Type.GetType("System.String"));
int idCount = 1;
foreach (Entity leave in listEntities.Entities)
DataRow dr;
dr = dt.NewRow();
dr["Id"] = idCount++;
dr["EventStartDate"] = Convert.ToDateTime(leave.Attributes["createdon"].ToString());
dr["EventEndDate"] = Convert.ToDateTime(leave.Attributes["modifiedon"].ToString());
dr["EventHeader"] = leave.Attributes["fullname"].ToString();
dr["EventDescription"] = leave.Attributes["fullname"].ToString();
dr["EventForeColor"] = "Navy";
CCGlobalCalendar.EventStartDateColumnName = "EventStartDate";
CCGlobalCalendar.EventEndDateColumnName = "EventEndDate";
CCGlobalCalendar.EventDescriptionColumnName = "EventDescription";
CCGlobalCalendar.EventHeaderColumnName = "EventHeader";CCGlobalCalendar.EventBackColorName = "EventBackColor";CCGlobalCalendar.EventForeColorName = "EventForeColor";
CCGlobalCalendar.EventSource = dt;

That’s it we are there. You can find the sample here

Hope it helps someone 🙂

What’s the problem with ThisWeek in advanced find

April 6, 2012 3 comments

Normally we consider week from monday to sunday but when we set “ThisWeek” criteria in advanced find CRM is taking sunday to Saturday.

To change this and set monday to sunday as criteria we can use system settings.

Go to settings->system settings switch to format tab click on customize change start day to monday

Hope this helps 🙂

Edit user profile link in Application Ribbon

In one of our implementation we have more than 10 realted entities for user entity. Users need to update information for their user account based on other tasks. To update the user information users need to open logged in user record from file–>options–>view your user information. Insted of doing this every time we thought of having a link in application ribbon to open user information. Here we go

Create a java script web resource (new_userinfo.js) with a function to open logged in user record. Here is the function you can use to open logged in user record

function openuserinfo()

Now we need to call this function from ribbon button. Create a solution and add Application Ribbon and new_userinfo.js web resource components to it and export the solution.

Extract the file and open customizations.xml to add the ribbon button.

Add Custom Action and Command Definitions for button. Use the below code

<CustomAction Id="Sample.{!EntityLogicalName}.MainTab.LaunchURL.CustomAction" 
<Button Id="Sample.{!EntityLogicalName}.MainTab.LaunchURL.Button" 
LabelText="Edit My Profile" 
ToolTipTitle="Edit My Profile" 
ToolTipDescription="Edit My Profile" 
TemplateAlias="o3" />

<CommandDefinition Id="Sample.all.MainTab.LaunchURL.Command">
<EnableRules />
<DisplayRules />
<JavaScriptFunction Library="$webresource:new_userinfo.js" FunctionName="openuserinfo" />

Save the customizations file and import the solution. Publish the customizations to see the link in application ribbon.

But this link will be available only when you select entities, I mean this link will not be available when you select Dashboards, Calendar, Announcements or default links in Settings