Display Sr No Column in List/Grid

By | March 26, 2012

In Sage CRM we are able to view the Customer related details in a list format for e.g. Customer Address, Cases, Communication, documents. These details are displayed in List or Grid format in CRM.
Using list format we can provide a variety of functionalities in CRM for e.g. we can add a hyperlink for customer’s ‘name’ column, display images in ‘status’ column of case and communication list etc. We can apply sorting on column header as well.
Mostly client’s requirements are similar to what is explained above; but in other scenarios client’s requirement were altogether different wherein client wanted to add checkbox, image column in list. On the same lines I once encountered a requirement wherein client had asked to display ‘Sr. No’ (Serial No) column in case list screen (Refer the attached screen-shot 1 below).

To further add to the complications, the ‘Sr. No’ should still be applied even if the end user has filtered the search and a new list had to be displayed. (Refer the attached screen-shot 2 below).

So in order to implement this customization we analyzed the functionality and followed the below given steps to achieve the same.
1. Log on to Sage CRM
2. Go to Administration-> Customization-> Case ->Fields
3. Click on the new button to create new field with name of Sr No
4. Click on the save button
5. Go to Administration-> Customization-> Case ->List
6. Click on the list name hyperlink column
7. Select Sr No field from field list
8. Click on the Add button and save button
9. We have created below given JavaScript code to implement Sr No column value.
< script for=window event=onload >
Display Sr No in List
MyGrid = getGrid();
if(MyGrid)
{
AddSRNo (MyGrid);
}
< /script >
< script >
//’ This Function user for find List or Grid object from List
function getGrid()
{
var allCells = document.getElementsByTagName(“TD”);
var boolGridPresent = false;
for(i=0;I < allCells.length;i++)
{
if(allCells[i].className==”GRIDHEAD”)
{
var parentspan = allCells[i].parentNode;
while (parentspan.nodeName != “TABLE”)
{
parentspan = parentspan.parentNode;
}
targetTable = parentspan;
return targetTable;
break;
}
}
}
//’ This function use for display SR No in column
function AddSRNo(Grid)
{
CommLinkColm = 1
checkboxcolno = 0
SrNoClolNo=2;
var CurrRowNo = 1
var CurrRowEle
var SrNoCol;
iPageNumberCount=0;
//’ Get GridSize form Server Side
iGridRowCount=’ < %=iGridSize% >’
iSrNoCount=0;
//’ Get Current Page Count
if(document.EntryForm.EnterPageNumber_BulkReassignmentGrid)
iPageNumberCount=document.EntryForm.EnterPageNumber_BulkReassignmentGrid.value;
//’ Page Count is Greater than Zero
if(iPageNumberCount>0)
{
iSrNoCount=parseInt(iGridRowCount*iPageNumberCount)
iSrNoCount=iSrNoCount-iGridRowCount+1;
}else
{
iSrNoCount=1
}
while (CurrRowNo < Grid.rows.length)
{
//’Get current row
CurrRowEle = Grid.rows[CurrRowNo];
SrNoCol = CurrRowEle.cells[SrNoClolNo];
//’Get InnerHTML of next column and current id from the hyperlink
NextCol = CurrRowEle.cells[CommLinkColm]
NextColInHtml = new String(NextCol[“innerHTML”])
if(NextColInHtml==”” || NextColInHtml==”undefined” || NextColInHtml==” “)NextColInHtml=””;
if(NextColInHtml!=””)
{
//’ Display SR No in List colnum
SrNoCol[“innerHTML”] = iSrNoCount++;
}
//’Increment row number
CurrRowNo++;
}
}
< /script >