开发者

Modifying main Activities grid view in CRM 4.0 using JavaScript

I have a task to change envelope icons on the main Activities view page (Work P开发者_开发问答lace, My Work -> Activities) for every row in the grid, depending on the custom status of the row in crm 4.0. I need to do it using JavaScript. Does anybody know if there is a way to do that and where should the JavaScript code be placed? I am assuming that I need to intercept grid onLoad event, go through the grid, check the condition and flip the url of the icon. But I cannot figure out how to hook into that event...

Thanks very much!

I got several very useful advices and here is what I got so far.

1. I added SiteMap to load a custom page, instead of default one (/workplace/home_activities.aspx)

2. Here is the code of the custom page, placing onreadystatechange in the html was the only way I could get this function to run. Do not know why.

 
HTML>
HEAD>
TITLE>
script language="javascript" type="text/javascript">
function Run()
{
 var objIframe = getIframe();

   if(objIframe.readyState == "complete")
   {
    var docFrame = objIframe.contentWindow.document;
    var grid = docFrame.getElementById("crmGrid");

    var allRecords = grid.InnerGrid.AllRecords;

    for(var i=0; i 

function getIframe()
{
   return document.getElementById("wraperActivitiesFrame");
}
/script> /HEAD> body > iframe id="wraperActivitiesFrame" src="/workplace/home_activities.aspx" WIDTH="100%" HEIGHT="100%" onreadystatechange="Run()"> /HTML>

The issue I am having now is that the function does not run again when I try to page the grid. I have 2 pages of Activities; when the page loads for the first time - I have my alert boxes, but when I click on "page 2" arrow - nothing happens. Why??? What I am doing wrong?


You kinda can hook into that event. You create a "wrapper" HTML page that you load in CRM instead of the default activities grid via Sitemap. This wrapper contains a full-size IFrame in which you load the actual grid, and in the IFrame's onreadystatechange handler (for readyState == 4), you traverse the grid's DOM (jQuery might make this a little easier, but I haven't used jQuery much myself) and do whatever changes you need to do (that means the JavaScript goes within the wrapper HTML page). If you call this via setInterval and put a try-catch around it, this will even be safe against grid refreshes and browsing through the pages.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜