Skip to content

Scrolling Announcements on Home Page for CRM 4.0

Lately, I’ve started looking into problems people face when dealing with CRM. Well it is a part of my job and provides me a great learning opportunity.

A day or two before I got this requirement : The end user wanted to scroll Announcements[CRM entity : newsarticle] on top of home page. I made a simple script which can be used. This one fetches all Announcements so you might want to set some filters like expiry date or active on date.

Here are the steps to scroll announcement on CRM Home page. Kindly note that I do not take any responsibility if something goes wrong with this approach.
1. Go to CRMWeb\_root\ and take backup of bar_top.aspx and keep it safe somewhere. In case things goes wrong, you will need it to restore things back.
2. Open bar_top.aspx in Visual Studio
3. Add the following code snippet at the end of the file.

<!– SCRIPT BEGIN : Scroll Announcements –>

<script type=”text/javascript” language=”javascript”>
window.attachEvent(‘onload’, ScrollAnnouncement);

function ScrollAnnouncement() {
var xml = “” +
“<?xml version=\”1.0\” encoding=\”utf-8\”?>” +
“<soap:Envelope xmlns:soap=\”http://schemas.xmlsoap.org/soap/envelope/\” xmlns:xsi=\”http://www.w3.org/2001/XMLSchema-instance\” xmlns:xsd=\”http://www.w3.org/2001/XMLSchema\”>”
+ GenerateAuthenticationHeader()
+
” <soap:Body>” +
” <Execute xmlns=\”
http://schemas.microsoft.com/crm/2007/WebServices\”>” +
” <Request xsi:type=\”RetrieveMultipleRequest\” ReturnDynamicEntities=\”true\”>” +
” <Query xmlns:q1=\”
http://schemas.microsoft.com/crm/2006/Query\” xsi:type=\”q1:QueryExpression\”>” +
” <q1:EntityName>businessunitnewsarticle</q1:EntityName>” +
” <q1:ColumnSet xsi:type=\”q1:ColumnSet\”>” +
” <q1:Attributes>” +
” <q1:Attribute>articletitle</q1:Attribute>” +
” </q1:Attributes>” +
” </q1:ColumnSet>” +
” <q1:Distinct>false</q1:Distinct>” +
” </Query>” +
” </Request>” +
” </Execute>” +
” </soap:Body>” +
“</soap:Envelope>” +
“”;

var xmlHttpRequest = new ActiveXObject(“Msxml2.XMLHTTP”);

xmlHttpRequest.Open(“POST”, “/mscrmservices/2007/CrmService.asmx”, false);
xmlHttpRequest.setRequestHeader(“SOAPAction”, “http://schemas.microsoft.com/crm/2007/WebServices/Execute“);
xmlHttpRequest.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);
xmlHttpRequest.setRequestHeader(“Content-Length”, xml.length);
xmlHttpRequest.send(xml);

var resultXml = xmlHttpRequest.responseXML;

var entityNode = resultXml.selectNodes(“//BusinessEntities”)[0];
var marqueeHTML = “<marquee class=’ms-crm-MastHead-SignIn-User’>”;
for (var i = 0; i < entityNode.childNodes.length; i++) {
if (i == 0) {
marqueeHTML += entityNode.childNodes[i].childNodes[0].childNodes[0].text
} else {
marqueeHTML += “&nbsp; &nbsp; ” + entityNode.childNodes[i].childNodes[0].childNodes[0].text;
}
}
marqueeHTML += “<marquee>”;

var headerTD = document.getElementById(“tdLogoMastHeadBar”);
headerTD.innerHTML += marqueeHTML;
}
</script>

<!– SCRIPT END : Scroll Announcements –>

4. Check on home page.
You will see a scrolling marquee of the announcements title on CRM Header.

Leave a Reply

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