How to select All records from the list with single checkbox by using JavaScript in Sage CRM?

By | July 29, 2017

As we all knows that Sage CRM fully supports client side scripting languages like JavaScript, JQuery etc. There can be a various purpose of using JavaScript in CRM but commonly we use for hide and show of fields or to populate value in one selection field based on selection made in another field.

Today we will guide you about new functionality that can be implemented in CRM by using JavaScript and it is nothing but the remove column name from the list and add “Checkbox” functionality in the same.

New Stuff: How to disable Embedded Email Editor in Sage CRM?

Recently one of our client came up with the requirement, where they need a provision to select all records from the list with single checkbox. To achieve this requirement, follow the below mentioned steps.

We have added one column in the list highlighted in Red in below mentioned screenshot.

Once we are done with the same we need to call .js in the custom content of that list.
<script src=”../CustomPages/Case/Cases.js”></script>
In my scenario, I am making changes in CaseList.
This Case.js file contains below mentioned code to convert column highlighted in above screenshot into check boxes.
function AddCheckBoxes()
{ CommLinkColm = 0
checkboxcolno = 10
SrNoClolNo=0;
var CurrRowNo = 1
var CurrRowEle
var checkboxCol;
var SrNoCol;
var ArrColHtml=””;
iPageNumberCount=0;
iGridRowCount=50;
iSrNoCount=0;
//’ Get Current Page Count
while (CurrRowNo < Grid.rows.length)
{
//’Get current row
CurrRowEle = Grid.rows[CurrRowNo];
//’Get the desired colum in which checkbox is to be added
checkboxCol = CurrRowEle.cells[checkboxcolno];
SrNoCol = CurrRowEle.cells[SrNoClolNo];
//’Get InnerHTML of next column and current id from the hyperlink
var NextCol = CurrRowEle.cells[CommLinkColm]
var NextColInHtml = NextCol[“innerText”];
if(NextColInHtml==”” || NextColInHtml==”undefined” || NextColInHtml==”&nbsp;” || NextColInHtml==”RefId “)NextColInHtml=”0”;
//alert(“NextColInHtml : “+NextColInHtml);
if(NextColInHtml!=”” && NextColInHtml!=’RefId ‘)
{
if(NextColInHtml==”RefId “)
{
CaseRefId=0;
}
else
CaseRefId = NextColInHtml
var string=”RefId”;
if(string.indexOf(NextColInHtml) !== 1)
{
}
else
{
CaseRefId=0;
}
CaseRefId=CaseRefId.replace(/\s/g,”)
if(CaseRefId!=””)
{
//alert(“not null”);
if(CurrRowNo==”1″)
{
CheckBoxHtml = “”;
CheckBoxHtml += “<input type=checkbox class=customcheck id=SelectAll name=SelectAll>”;
//’Set HTML in checkbox column
checkboxCol[“innerHTML”] =CheckBoxHtml
}
else
{
if(CaseRefId!=” “)
{
CheckBoxHtml = “”;
CheckBoxHtml += ‘<input type=checkbox class=customcheck id=chkemp_”‘+CaseRefId'” name=chkemp_”‘+CaseRefId+'”>’;
//’Set HTML in checkbox column
checkboxCol[“innerHTML”] =CheckBoxHtml
}
}
}
}
CurrRowNo++;
}
}
Now we need to bind event to top checkbox and for that we need to add below code.
About Us
Greytrix a globally recognized Premier Sage Gold Development Partner is a one stop solution provider for Sage ERP and Sage CRM needs. Being recognized and rewarded for multi-man years of experience, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third party add-on development and implementation expertise.

Greytrix has some unique integration solutions for Sage CRM with Sage ERPs (Sage Enterprise Management (Sage X3), Sage Intacct, Sage 100Sage 500 and Sage 300).We also offer best-in-class Sage ERP and Sage CRM customization and development services to Business Partners, End Users and Sage PSG worldwide. Greytrix helps in migrating of Sage CRM from Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes Greytrix Business Manager, Sage CRM Project Manager, Sage CRM Resource Planner, Sage CRM Contract Manager, Sage CRM Event Manager, Sage CRM Budget Planner, Gmail Integration, Sage CRM Mobile Service Signature and Sage CRM CTI Framework.

Greytrix is a recognized Sage Rockstar ISV Partner for GUMU™ Sage Enterprise Management – Sage CRM integration also listed on Sage Marketplace.

For more information on our integration solutions, please contact us at [email protected]. We will be glad to assist you.