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:

crm.ready(function()
{
var sReportName=””;
$(“a.TOPBC”).each(function(){

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

if(sReportName==”Your Report Name”)
{
$(‘a#Button_Go’).attr(“onclick”,”javascript:CheckDates();”);
}
});
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(‘/’);
Start_FetchDate1=Start_FetchDate1[1]+”/”+Start_FetchDate1[0]+”/”+Start_FetchDate1[2];

var End_FetchDate1=End_FetchDate.split(‘/’);
End_FetchDate1=End_FetchDate1[1]+”/”+End_FetchDate1[0]+”/”+End_FetchDate1[2];

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));

if(diffDays>31)
alert(“Please select date range of one month.”)
else
$(‘a#Button_Go_IMG’).click();
}

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 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 sage@greytrix.com. We will be glad to assist you.