Custom filter screen with default filter on Date Field options

By | January 3, 2011

Earlier I had posted a blog:

http://sagecrmaddons.blogspot.com/2010/12/date-ing-tips.html

In which I had elaborated how to handle the date field in the custom search screen as it is little bit tedious task to do.

Now in this section I will be more descriptive on how to make the date field default in the custom filters.

Some days ago my client was came up with the requirement that they would like to have a custom list prefilled based on the last week so that the system performance would be improved. The entries which have been made within last week should auto-populated whenever user visits the screen first time. I had done some RND stuff and came to know that yes it can be doable in Sage CRM. We can set the default values in the date field which looks something like:

In order to achieve this we just need to do client side coding to set the corresponding list and field values. I searched on forum and found the code for the same which was like:

Script

window.attachEvent(“onload”,fillfields);

function GetKeyValue(querystringname)
{
var strPath = window.location.search.substring(1);
var arrayKeys = strPath.split(” & “);
for (var i=0;i< arrayKeys.length;i++)
{
var arrayValue = arrayKeys[i].split(“=”);
if (arrayValue[0].toLowerCase()== querystringname.toLowerCase())
{
return arrayValue[1];
}
}
return “”;
}

function fillfields()
{
if (!document.getElementById(‘HIDDENPAGENUMBER’))
{
document.forms[0].DateTimeModescomm_datetime.selectedIndex=1;
var bRelative = (document.forms[0].DateTimeModescomm_datetime.value == ‘Relative’);
document.all.divcomm_datetimeBetween.style.visibility = (!bRelative) ? ‘visible’ : ‘hidden’;
document.all.divcomm_datetimeRelative.style.visibility = (bRelative) ? ‘visible’ : ‘hidden’;
}
}

Actually whenever we add a date field on the search screen CRM internally creates few of the fields to handle its functionality like:

– DateTimeModescomp_uploaddate
– comp_uploaddate_relative
– divcomp_uploaddateBetween

We need to set the expected value whenever screen loads first time.

Hope everybody would like to implement this to improve the performance of CRM if the large amount of data to be loaded in the list.

For queries regarding the functionality, please feel free to drop us an email at crm@greytrix.com.