Sunday, October 11, 2009

CRM 4.0 Make your announcements come to life




CRM has a nice feature (or at least a decent idea) called announcements which allows you to integrate and share textual messages with all CRM users.
The main issue with announcements is that the body or description field does not interprets hyper text.

Now wouldn’t it be nice to be able to integrate reach html messages into CRM using announcements. Although you can easily create your own reach text announcement mechanism and integrate it into CRM site map I actually find it more appealing leveraging an existing feature.

In order to force the announcement page support HTML is made a simple modification to the home / homepage / home_news.aspx. now, since modifying CRM files is unsupported consider the ramification before actually doing so.

The home_news.aspx page contains html that looks like this:

<body>

<table width="100%" height="100%">
<tr>
<td>
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<div style="width:100%;height:100%;overflow-y:scroll;padding:10px; border: 1px solid #cccccc; background-color:#ffffff;">
<table width="100%" height="100%" cellspacing="2" cellpadding="3" border="0" style="table-layout:fixed;">
<col width="20"><col>
<% =RenderAnnouncements(false) %>
<tr height="100%" colspan="2"><td> </td></tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>


If you take a closer look at the generated html (using iedevtoolbar) you’ll notice that the announcement messages are rendered as table rows. I wanted to make as little change to this page as possible and still support HTML. In order to do so I used a simple technique which wraps the inner body content (table element) in a textarea and reads the textarea value into a new span element as innerHTML.

Here is how the page looks like after the modification is made:

<body>

<textarea style="display:none" id="anntext">
<table width="100%" height="100%">
<tr>
<td>
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
<div style="width:100%;height:100%;overflow-y:scroll;padding:10px; border: 1px solid #cccccc; background-color:#ffffff;">
<table width="100%" height="100%" cellspacing="2" cellpadding="3" border="0" style="table-layout:fixed;">
<col width="20"><col>
<% =RenderAnnouncements(false) %>
<tr height="100%" colspan="2"><td> </td></tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</textarea>

<span id="annhtml"></span>
<script> 
window.document.all.annhtml.innerHTML = document.all.anntext.value;
</script>

</body>


One thing that you need to minded of is that the html you paste in the announcement body should be a one liner. This is because the line breaks are interpreted as br elements.

That’s all, enjoy your new announcement feature.

1 comment:

oracle fusion said...

I read your articles very excellent and the i agree our all points because all is very good information provided this through in the post. It is very helpful for me. Keep blogging like this. Thanks.

Oracle Fusion Financial Training Institute