Question
Bank of New Zealand
IN
Last activity: 27 Jun 2016 21:42 EDT
Date Time field defaults to current time after upgrade
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 12:00 AM but in Pega 7.1.7 it defaults to current time.
I verified the related Support Article SA-12489.
PegaSystems suggested the following change to make the time defaulted to "00:00"
1. Create a non-auto generated section with below code.
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 12:00 AM but in Pega 7.1.7 it defaults to current time.
I verified the related Support Article SA-12489.
PegaSystems suggested the following change to make the time defaulted to "00:00"
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.
but this approach is not working. still the date time is set to current date time. Is there anything else we need to do to set the time to "12:00 AM" or 00:00?
Message was edited by: Joe Stalin Thanks for your response, I will check and reply you soon. Joe Stalin
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pega Systems
IN
Can you try setting "Date/Time" value to "Auto" on Presentation tab for this control in the section?
Bank of New Zealand
IN
Hi Sarang,
Thanks for your update. apologies for the delay i was leave for the past 3 days. thanks for your suggestion and reply. while i am checking, by default the "Date/Time" value set as "Auto" on the presentation tab.
Thanks,
Joe Stalin.
Pegasystems Inc.
IN
Hello Joe,
Could you please try the below solution.
- Create a non-auto generated section with below code.
<script>
try {
var dateTimeControlsIDs = [""]; /*List of span ids of dateTime control, eg:- "$PpyWorkPage$pMyDateTimeProp1Span","$PpyWorkPage$pMyDateTimeProp2Span"*/
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;
}
}
Hello Joe,
Could you please try the below solution.
- Create a non-auto generated section with below code.
<script>
try {
var dateTimeControlsIDs = [""]; /*List of span ids of dateTime control, eg:- "$PpyWorkPage$pMyDateTimeProp1Span","$PpyWorkPage$pMyDateTimeProp2Span"*/
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>
- Include this section, into your master section, where you want to use the 0:00 time settings.
Please test the above solution and get back to us with your findings.
Regards,
Ajit
Bank of New Zealand
IN
Hi Ajit,
Thanks for your update. Apologies for the delay I was on leave for the past 3 days. thanks for your suggestion, could you please tell me what are the additional changes you have done in the above code except the highlighted yellow one which is commented. I believe there is no change in the script and highlighted lines also commented. but i tried by applying the scripts but still we are not getting the expected result. Thanks for your time for this issue.
Thanks,
Joe Stalin
Pegasystems Inc.
IN
hello Joe,
The variable array (var dateTimeControlsIDs = [""]; should contain the list of SPAN ids as highlighted in my previous comment.
Like this
<script>
try {
var dateTimeControlsIDs = ["$PpyWorkPage$pLastQuestionSpan"]; /*List of span ids of dateTime control, eg:- "$PpyWorkPage$pMyDateTimeProp1Span","$PpyWorkPage$pMyDateTimeProp2Span"*/
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) {
hello Joe,
The variable array (var dateTimeControlsIDs = [""]; should contain the list of SPAN ids as highlighted in my previous comment.
Like this
<script>
try {
var dateTimeControlsIDs = ["$PpyWorkPage$pLastQuestionSpan"]; /*List of span ids of dateTime control, eg:- "$PpyWorkPage$pMyDateTimeProp1Span","$PpyWorkPage$pMyDateTimeProp2Span"*/
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>
Also make sure that the datetime control has been configured to support 24 hours format.
Please test the above solution and get back to us with your findings.
Regards,
Ajit
Bank of New Zealand
IN
Pegasystems Inc.
IN
Hello Joe,
Your Locale should have default support for 24 hours format. For testing you may use, en_GB.
Regards,
Ajit
Bank of New Zealand
IN
Hi Ajit,
appreciated your continuous support....:) I changed the Locale as mentioned, but we are getting the current date time again...
Thanks,
Joe Stalin
Updated: 27 Jun 2016 21:42 EDT
Bank of New Zealand
IN
HI Ajit,
As you mentioned in the above, the dateTimeControlID whcih i mentioned was wrong for my date field. I found my SPAN id in Developers tool. I got the expected result as default to 12:00 AM.
for everyone's benefit I am posting this solution..:)
the below code resolved my issue.
<script>
$( document ).ready(function() {
console.log( "ready!" );
attachOnclickforTime();
});
function attachOnclickforTime(){
try {
var dateTimeControlsIDs = ["$PGCRReports$pFromDateSpan","$PGCRReports$pToDateSpan"];
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) {
HI Ajit,
As you mentioned in the above, the dateTimeControlID whcih i mentioned was wrong for my date field. I found my SPAN id in Developers tool. I got the expected result as default to 12:00 AM.
for everyone's benefit I am posting this solution..:)
the below code resolved my issue.
<script>
$( document ).ready(function() {
console.log( "ready!" );
attachOnclickforTime();
});
function attachOnclickforTime(){
try {
var dateTimeControlsIDs = ["$PGCRReports$pFromDateSpan","$PGCRReports$pToDateSpan"];
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 == 12) {
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;
}
}
var amPmDropObj = document.getElementById("amPmDrop");
debugger;
listLength = amPmDropObj.options.length;
debugger;
for (var i = 0; i < listLength; i++) {
if (amPmDropObj.options[i].value == "AM") {
amPmDropObj.options[i].selected = true;
amPmDropObj.options[i].defaultSelected = true;
}
}
}
}, 100);
}
</script>
but one more interesting thing is, this solution is working for Chrome browser and IE 11 (Windows 7 machines) browser but not working for IE 8 (XP machines) browser
if any one know the solutions. Please let us know.
Thanks,
Stalin A
Bank of New Zealand
IN
Hi Ajit,
Thanks for the quick response... I will make the change and get back to you with the outcome.
Appreciated for your response.