Support Article
Date Time field defaults to current time after upgrade
SA-12489
Summary
Issue with the Date-Time Calendar after upgrading from PRPC 6.1 to Pega 7.1.7. In the earlier version, the time is defaulted to 0:00 AM but in Pega 7.1.7 it defaults to current time.
Error Messages
Not Applicable
Steps to Reproduce
1. Add Date Time control to a Date Time type property.
2. On clicking the Date calendar field the time is defaulted to current time which was not the case in PRPC 6.1.
Root Cause
The root cause of this problem is a defect in custom application code/rules.
Resolution
This issue is resolved through the following local-change:
1. Create a non-auto generated section with below code.
<script>
try {
var dateTimeControlsIDs = [""];
debugger;
for (var idx = 0; idx < dateTimeControlsIDs.length; idx++) {
var iconSpanObj = document.getElementById(dateTimeControlsIDs[idx]);
if (iconSpanObj) {
pega.util.Event.removeListener(iconSpanObj, 'click', setDefaultHoursAndMinutes);
pega.util.Event.addListener(iconSpanObj, 'click', setDefaultHoursAndMinutes);
}
}
} catch(e) { }
function setDefaultHoursAndMinutes(event) {
var _element = pega.util.Event.getTarget(event);
setTimeout(function() {
if (_element && _element.parentNode) {
var inputElem = pega.util.Dom.getFirstChild(_element.parentNode);
if (inputElem && inputElem.value != "") {
return;
}
}
var hoursDropObj = document.getElementById("hourDrop");
if(hoursDropObj) {
var listLength = hoursDropObj.options.length;
for (var i = 0; i < listLength; i++) {
if (hoursDropObj.options[i].value == 0) {
hoursDropObj.options[i].selected = true;
hoursDropObj.options[i].defaultSelected = true;
}
}
var minuteDropObj = document.getElementById("minuteDrop");
listLength = minuteDropObj.options.length;
for (var i = 0; i < listLength; i++) {
if (minuteDropObj.options[i].value == 0) {
minuteDropObj.options[i].selected = true;
minuteDropObj.options[i].defaultSelected = true;
}
}
}
}, 100);
}
</script>
2. Include this section, into the master section, where you want to use the 0:00 time settings.
Published July 30, 2015 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.