SugarCRM Customization: Creating the Date-Time Combo

by

SugarCRM customization is a matter of interest for many organizations however there are a few modifications that people can execute in-house with little technical help as they are so simple that all you need to implement them is an average functional brain and a computer. Creating the date-time combo is one such solution that does not require too much technical assistance to be implemented. You can easily carry it out by following the given code snippet you’ll need in JavaScript:

var now = new Date();
if (now.getMonth() == 11) {
var currentTime = new Date(now.getFullYear() + 1, 0, 1);
} else {
var currentTime = new Date(now.getFullYear(), now.getMonth() + 1, 1);
}
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
day = day.toString();
month = month.toString();

if(day.length == ‘1’)
day = ‘0’ + day;

if(month.length == ‘1’)
month = ‘0’ + month;

var defaultDate = month + ‘/’ + day +’/’ + year;
var datetimecombo = ‘

LABEL_OF_YOUR_FIELD* Enter Date 
 : 

‘;

You can get the date logged in using the following code:

var todayDate = new Date();
var todayDateinUserFormat = todayDate.toLocaleFormat(cal_date_format);
alert(todayDateinUserFormat);

If everything goes right then you’ll have your desired date-time combo in SugarCRM. You can now congratulate yourself on the successful endeavor.


Leave a Reply

Your email address will not be published. Required fields are marked *