Duration Type field auto conversion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 03:36 AM
Hi All,
We have duration type field on the form , and if the user enters more than 24 hours in the hours field it automatically converts to 1 day , for example : "Days 00 Hours 25 Minutes 00 Seconds 00" now if I save the record it would automatically convert to "Days 01 Hours 01 Minutes 00 Seconds 00".
My requirement is that if user enters more than 8 hours under hours field it should throw an error saying please enter hours less than or equal to 8.
But whenever I tried to obtain the value of the field it always converts the hours to equivalent number of days if hours are entered greater than 24. I tried in both from front end in Client Script and backend in Business Rule as well.
Any ideas on how to get around this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 03:50 AM
Hello,
try this onChange Client Script code, replace <duratiion field> with your field name:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '')
return;
var duration = g_form.getIntValue('<duration field>');
if (duration > 8 * 60 * 60 ) {
g_form.showFieldMsg('<duration field>', getMessage('Maximum allowed duration is 8 hours'), 'error');
}
}
Also you can reuse the code logic in your onSubmit Client Script.
If my answer helped you, please mark it as correct and helpful, thank you 👍
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 04:01 AM
This will not help as I will be getting value in seconds and I will never know how many days user entered along With hours.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 04:34 AM
Now I understand. Unmark my answer as correct as it doesn't meet your requirement.
I don't know how to achieve it.