Time Zone

Jun 8, 2010 at 7:59 PM

I want to know if the portal can display the creation date of the case, in the same zone of contact. If this is possible, someone could give me a hint?



Discover the new Windows Vista Learn more!
Jun 11, 2010 at 4:48 PM
Edited Jun 11, 2010 at 4:50 PM

Hi RC,

Yes, you most certainly can accomplish this.  In the code files, locate and open the "ViewCases.aspx.cs" file.  You will need to add the following to the code:

Add the followng GetUserMinutesFromGmt method.

private static int GetUsersMinutesFromGmt(int? timeZoneCode, XrmDataContext crmContext)
   return crmContext.timezonedefinitions.First(timeZone => timeZone.timezonecode == timeZoneCode).lk_timezonerule_timezonedefinitionid.First().bias.GetValueOrDefault() * -1; 

Then modify CaseList_OnRowDatasBound, located on line 74, as shown below:

protected void CaseList_OnRowDataBound(object sender, GridViewRowEventArgs e)
  var contact = SiteContext.Current.CurrentUserContact as contact;
  var crmContext = new XrmDataContext();
  var usersMinutesFromGmt = GetUsersMinutesFromGmt(contact.adx_timezone, crmContext);

  if (e.Row.RowType != DataControlRowType.DataRow || e.Row.Cells.Count < 1)

   e.Row.Cells[0].Text = string.Format(@"<a href=""{0}"">{1}</a>",

   foreach (TableCell cell in e.Row.Cells)
      DateTime cellAsDateTime;

      if (DateTime.TryParse(cell.Text, out cellAsDateTime))
          cell.Text = cellAsDateTime.ToUniversalTime().AddMinutes(usersMinutesFromGmt).ToString("g");

Christine Fischer – Developer
Adxstudio Inc. 

Mar 16, 2011 at 10:38 PM

Christine, I have used your code sample here on my CRM Portal, and it's been working great.  Now that we've "sprung ahead", I'm finding that when viewing CRM Data through the portal, the times are off by 1 hour.  So it appears that this method does not account for Daylight Savings?

Wondering what the best method is to modify the code above for Daylight Savings?

Thank you,

Millie Burns