- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2022 04:12 AM
I am using onChange Client Script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var originalValue = g_form.getValue("end_date");
if (isLoading || newValue === '' || originalValue === '') {
return;
}
if (new Date(newValue) > new Date(originalValue)) {
// alert("End date: " + originalValue + " start Date:" + newValue);
g_form.setValue("end_date", newValue);
g_form.showFieldMsg('end_date', "The selected Date (" + originalValue + ") was before the selected Start Date. End Date has been reset to the Start Date ", 'warning');
}
}
I want warning message to be clear out after 5 seconds as after script runs is finished.
How can I achieve this functionality?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2022 05:09 AM - edited 12-25-2022 05:21 AM
Hi @Tejas16,
Try this updated scripts and make sure to set Isolate scripts check box to false.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var originalValue = g_form.getValue("end_date");
if (isLoading || newValue === '' || originalValue === '') {
return;
}
if (new Date(newValue) > new Date(originalValue)) {
// alert("End date: " + originalValue + " start Date:" + newValue);
g_form.setValue("end_date", newValue);
g_form.showFieldMsg('end_date', "The selected Date (" + originalValue + ") was before the selected Start Date. End Date has been reset to the Start Date ", 'warning');
}
window.setTimeout(hideFieldMessages, 5000);
}
function hideFieldMessages() {
g_form.hideFieldMsg("end_date"); // updated your field name to end_date
}
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2022 05:09 AM - edited 12-25-2022 05:21 AM
Hi @Tejas16,
Try this updated scripts and make sure to set Isolate scripts check box to false.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var originalValue = g_form.getValue("end_date");
if (isLoading || newValue === '' || originalValue === '') {
return;
}
if (new Date(newValue) > new Date(originalValue)) {
// alert("End date: " + originalValue + " start Date:" + newValue);
g_form.setValue("end_date", newValue);
g_form.showFieldMsg('end_date', "The selected Date (" + originalValue + ") was before the selected Start Date. End Date has been reset to the Start Date ", 'warning');
}
window.setTimeout(hideFieldMessages, 5000);
}
function hideFieldMessages() {
g_form.hideFieldMsg("end_date"); // updated your field name to end_date
}
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2022 05:38 AM
Instead of using
window.setTimeout(hideFieldMessages, 5000);
we only require setTimeout(hideFieldMessages,5000);