- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 10:23 PM
Hi Team,
I need alret message if select more then 12 hours in duration variable
I tried below client script and script include but it works
Client script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 01:40 AM - edited 07-24-2024 01:40 AM
Hi @Community Alums ,
Please try the below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var duration = g_form.getValue('how_long_do_you_need_access');
var parts = duration.split(" ");
var selectedDay = (parts.length > 1) ? Number(parts[0]) : 0;
var selectedHour = Number(parts[parts.length - 1].split(":")[0]);
var selectedMin = Number(parts[parts.length - 1].split(":")[1]);
var selectedSeconds = Number(parts[parts.length - 1].split(":")[2]);
var daysInHrs = selectedDay * 60; //Converting days into hours
var minInHrs = selectedMin / 60; //converting mins in hrs
var secInHrs = selectedSeconds / 3600; //converting secs in hrs
var finDur = daysInHrs + selectedHour + minInHrs + secInHrs;
//alert("Selected Days: " + selectedDay + " \nhours: " + selectedHour + " \nMinutes: " + selectedMin + " \nSeconds: " + selectedSeconds + " \nFinalDur: "+ finDur);
if (finDur > 12) {
alert('More than 12hrs detected');
}
}
More than 12 hrs selected:
Mark this as Helpful / Accept the Solution if this helps
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 10:31 PM
Hi @Community Alums
What is variable type for 'how_long_do_you_need_access' ?
If it is date or date/time - In script include you can use GlideDateTime()
Similar use case for your reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 10:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 11:07 PM
You can write in this way:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 11:25 PM