- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 04:30 PM
Hello community!
I have a question about the date/time field on a record producer.
Currently this field is draws time in the format of HH:mm:ss. Main issue with this is when users use Calendar to select date, the time is automatically filled to the current time. Including the seconds.
This causes issues when this selection is used to book in a slot of time.
E.G,
when user books from 13:00:02 until 14:00:02, when another user wants to book in 14:00:00 until 15:00:00, it would say the timeslot is not available.
It wouldn't be a good system if I have to have a label that says " please round off your times to the nearest minute"
So I was trying to find a way to make it so when a date/time is inputted into the field. this would trigger to always change the seconds into 00. Wondering if anyone else has ever had this issue, and how they have resolved it in the past. OR have any suggestions on how to do this that would be appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 08:22 PM - edited 02-13-2025 12:36 AM
Hi @LePhucTanT
We can set value of field when datetime field changes, for that you can use below on change client script in record producer.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(newValue){
var dateTime = newValue; //dateTime = `2025-02-14 10:20:30` where `slot` is date time field in record producer
var dateTimeArray = dateTime.split(" "); // ["2025-02-14","10:20:30"]
var timeArray = dateTimeArray[1].split(":"); // [ '10', '20', '30' ]
timeArray[2] = "00"; // time = [ '10', '20', '00' ]
dateTimeArray[1] = timeArray.join(":"); // dateTimeArray = ["2025-02-14","10:20:00"]
g_form.setValue("slot",dateTimeArray.join(" ")); //2025-02-14 10:20:00
return;
}
}
Output :
If this helps, please mark this as correct/helpful.
Regards,
Krishnamohan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 08:22 PM - edited 02-13-2025 12:36 AM
Hi @LePhucTanT
We can set value of field when datetime field changes, for that you can use below on change client script in record producer.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(newValue){
var dateTime = newValue; //dateTime = `2025-02-14 10:20:30` where `slot` is date time field in record producer
var dateTimeArray = dateTime.split(" "); // ["2025-02-14","10:20:30"]
var timeArray = dateTimeArray[1].split(":"); // [ '10', '20', '30' ]
timeArray[2] = "00"; // time = [ '10', '20', '00' ]
dateTimeArray[1] = timeArray.join(":"); // dateTimeArray = ["2025-02-14","10:20:00"]
g_form.setValue("slot",dateTimeArray.join(" ")); //2025-02-14 10:20:00
return;
}
}
Output :
If this helps, please mark this as correct/helpful.
Regards,
Krishnamohan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 05:44 PM
This works perfectly!
it was able to split the date and time, then change the value of ss every time the field was updated
appreciate your assistance.
Regards
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Worked perfectly first time by being both correct and helpful.
Thank you.
Reagrds
Stef
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2025 12:15 AM - edited 02-13-2025 12:17 AM
Hi @LePhucTanT
Yes, the seconds in a Date/Time field default to the current time when using the calendar picker. Let try my onChange client script below to reset seconds to 00 after selection:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue.endsWith('00')) {
return;
}
g_form.setValue('outage_start', newValue.slice(0, -2) + '00');
}
Cheers,
Tai Vu