Restrict time on schedule Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 06:22 AM
Hello Experts,
I want to acheive the below requirement
Restrict the slot 5am to 11am on creating a schedule report. How can i acheive this?
Thanks,
Nithya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2023 04:12 AM
Hi Nithya,
Here you go..
Create a onChange client script on "run_time" field. Use the below Script.
Alter error message as required.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var start = "05:00:00";
var end = "11:00:00";
if (g_form.getValue('run_time') >= 'start' && g_form.getValue('run_time') <= 'end') {
g_form.addErrorMessage("Time not allowed between 5 -11");
g_form.clearValue('run_time');
}
}
Please mark it correct if you find this useful!
Regards,
Karthiga
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2023 08:25 AM - edited ‎08-11-2023 08:27 AM
Hi Karthiga,
The script you mentioned below, if condition is not satisfied ,
g_form.getValue('run_time') >= 'start' is coming true but
g_form.getValue('run_time') <= 'end' is coming false
if (g_form.getValue('run_time') >= 'start' && g_form.getValue('run_time') <= 'end') { g_form.addErrorMessage("Time not allowed between 5 -11"); g_form.clearValue('run_time'); }
Thanks,
Nithya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2023 09:10 AM - edited ‎08-11-2023 09:11 AM
Hi @Community Alums ,
Try this, I have tested it.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var start = new Date();
start.setHours(5, 0, 0, 0);
var end = new Date();
end.setHours(11, 0, 0, 0);
var runTimeValue = g_form.getValue('run_time');
var time_separated = runTimeValue.split(":");
if (time_separated.length === 3) {
var currentHour = parseInt(time_separated[0]);
if (!g_user.hasRole('admin') && !isNaN(currentHour) && currentHour >= 5 && currentHour < 11) {
g_form.addErrorMessage("Report creation is not allowed between 5 AM and 11 AM.");
g_form.clearValue('run_time');
} else {
//allowed
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2023 03:15 AM - edited ‎08-12-2023 03:16 AM
Hello Nithya,
Adding with Variable works!
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var start = "05:00:00";
var end = "11:00:00";
var actual = g_form.getValue('run_time');
if ( actual >= start && actual <= end){
g_form.addErrorMessage("Time not allowed between 5 -11");
g_form.clearValue('run_time');
}}
Please mark it correct & helpful if you find this useful!
Thanks,
Nithya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2023 11:42 PM - edited ‎08-16-2023 11:52 PM
Hi Karthiga,
want the script for onSubmit because, the record should not be saved. while we using client script validation is happened but record is saved
Used the same validation for onSubmit but it is not worked
Can i have the script for onsubmit
Thanks,
Nithya.