Restriction on Date field for reports in Sage CRM

By | January 14, 2019

We all are familiar with Sage CRM’s Reporting tool, which helps to give a clear picture of ongoing work in very efficient manner. Just like many other features of CRM, even Reporting tool has some of its inbuilt features such as various report output options, chart options, sorting or grouping of output data etc. Even a simple Date field when added in search criteria, gives multiple options to filter the data. But have you ever tried to limit the report filtration by applying a specific condition on this Date fields?

New Stuff: Migrate Contact from Salesforce as Person in Sage CRM

On adding a Date field in Report’s search criteria, Sage CRM provides multiple options like specific date, Between, Relative like Day, Week, Month, Quarter or Year as shown in below screenshot.

However one of our Client came up with a requirement wherein, he needed to restrict the Date values in report’s search criteria for a month or two. Since the Between option was already available, we decided to apply the restriction with the help of some scripting as below.

1. Create JavaScript page in below path:
Program Files (x86)\Sage\CRM\Instance_Name\WWWRoot\js\custom

2. Add the below code in the JavaScript page you were created:

var sReportName=””;

sReportName=new String($(this).text());
if(sReportName==”” || sReportName==”null” || sReportName==”undefined”)sReportName=””;

if(sReportName==”Your Report Name”)
function CheckDates()
var Start_FetchDate=new String($(“#FieldName_start”).val());
if(Start_FetchDate==”” || Start_FetchDate==”null” || Start_FetchDate==”undefined”)Start_FetchDate=””;

var End_FetchDate=new String($(“#FieldName_end”).val());
if(End_FetchDate==”” || End_FetchDate==”null” || End_FetchDate==”undefined”)End_FetchDate=””;

var Start_FetchDate1=Start_FetchDate.split(‘/’);

var End_FetchDate1=End_FetchDate.split(‘/’);

var date1 = new Date(Start_FetchDate1)
var date2 = new Date(End_FetchDate1)
var timeDiff = Math.abs(date2.getTime() – date1.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));

alert(“Please select date range of one month.”)

3. Save the code and clear the browser cache files.

In this way you can now easily restrict the date field in Sage CRM as per the requirement like one month or two months etc.

About Us

Greytrix – a globally recognized and one of the oldest Sage Gold Development Partner is a one-stop solution provider for Sage ERP and Sage CRM organizational needs. Being acknowledged and rewarded for multi-man years of experience and expertise, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third party add-on development and implementation competence.

Greytrix has some unique integration solutions developed for Sage CRM with Sage ERPs namely Sage X3Sage IntacctSage 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 migration of Sage CRM from Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes addons like  Greytrix Business ManagerSage CRM Project ManagerSage CRM Resource PlannerSage CRM Contract ManagerSage CRM Event ManagerSage CRM Budget PlannerGmail IntegrationSage CRM Mobile Service Signature and Sage CRM CTI Framework.

Greytrix is a recognized Sage Champion ISV Partner for GUMU™ Sage X3 – Sage CRM integration also listed on Sage Marketplace.

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