MS CRM 4.0 Error in “presence.htc”

2008-05-08 Update:
Before I posted what I found, I had searched the web and found a usenet posting by Peter Zimmermann of www.ambit.ch asking the same question I was trying to answer.   I sent him a note about what I’d found.   He said they had dug through it and found the root of the problem is having contact with a blank last name.   Indeed, I found that on the page in question there were contacts that had been imported with no last name.   Thanks to Peter for the update and the further investigation.
— end update —

After upgrading a customer from MS CRM 3.0 to version 4.0, I discovered an error that kept popping up in the “do you want to report this to Microsoft box”.   The actual XML to be sent to MS included:

  <ScriptErrorDetails>
      <Message>Object required</Message>
      <Line>196</Line>
      <URL>/_static/_grid/presence.htc</URL>
      <PageURL>/OrgName/_root/homepage.aspx?etc=2</PageURL>
      <Function>prepareEnablePresence()</Function>
      <CallStack>
          <Function>prepareEnablePresence()</Function>
      </CallStack>
  </ScriptErrorDetails>

I isolated that the problem (at least in my case) only occurs when I have Windows Live messenger loaded.

After stepping through the code, I discovered that the error is indeed on lines 196 and 197 in presence.htc, which read:

var oImgSpan = oControl.firstChild;
if (oImgSpan.tagName == “IMG”)

The probelm is that oImgSpan.firstChild is null.   The workaround is to have line 197 check for the existence of the null, like this:

if ( (oImgSpan != null) && (oImgSpan.tagName == “IMG”) )

My disclaimer on this is that while this will stop the error from happening, it isn’t necessarily solving the root problem.   I haven’t had time to look at exactly what the code is doing.   Since it is in presence.htc and it only happens when Windows Live Messenger is running, I believe “presence.htc” is basically a behavior that is supposed to display an icon that indicates whether someone is online or not.   Where and how, I’m not sure.   Since the line in question is followed by logic to assign the src property of the image <SPAN>, it may or may not show things correctly.   If I have time, I’ll investigate further.   Right now, since my customer doesn’t allow their users to use Messenger, they won’t see the error.   I’ve advised them of the potential issue – they said leave it as is.   My work here is done.

This entry was posted in Code/Development, Microsoft CRM 4.0, Technology. Bookmark the permalink.

One Response to MS CRM 4.0 Error in “presence.htc”

  1. Mark says:

    Fantastic – well done – like you I feel there is maybe an underlying reason why it is happening but I dont have the time to find it right now

Leave a Reply

Your email address will not be published. Required fields are marked *