- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 01:55 AM
I have two date fields, start date and end date.
I have written oncell edit client script like below:
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
//Type appropriate comment here, and begin script below
var strDate = g_form.getValue('start_date');
var endDate = g_form.getValue('end_date');
if (endDate < strDate) {
alert("st= " + strDate + ' ' + "end= " + endDate);
}
callback(saveAndClose);
}
But it is not working. It working fine on onchnge client script.
Any suggestions?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 10:47 PM - edited 02-23-2024 12:02 AM
You can add an alert in the client script like the below:
Please mark this response as correct or helpful if it assisted you with your question.
Best Regards,
Rutuja Khalate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 05:53 AM - edited 02-22-2024 05:54 AM
when you are in a list, g_form (which works on the FORM) isn't available, that's why it doesn't work.
onCellEdit doesn't have access to the form, it gives you some control over fields on a list but you can't do conditional stuff like this.
There are 2 ways as below:
1. You can use a GlideAjax call in your onCellEdit() client script. You can retrieve the current value of your field.
2. To fulfill your requirement you can use a before insert/update business rule, set the condition and then in the actions tab tick the abort action box and add a message to your users.
Please mark this response as correct or helpful if it assisted you with your question.
Best Regards,
Rutuja Khalate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 06:36 AM - edited 02-22-2024 06:39 AM
Can you try below:
Client script on End Date field:
Please mark this response as correct or helpful if it assisted you with your question.
Best Regards,
Rutuja Khalate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 06:51 AM
This is working fine, but I have to show error message or alert message. If user enters end date before start date.
If I add alert, it is popping up in both scenarios. (+ve and -ve)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 10:47 PM - edited 02-23-2024 12:02 AM
You can add an alert in the client script like the below:
Please mark this response as correct or helpful if it assisted you with your question.
Best Regards,
Rutuja Khalate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2024 03:15 AM
Hi @Naga Ravindra R ,
Please mark this response as correct or helpful if it assisted you with your question.
Please mark this response as correct or helpful if it assisted you with your question.
Best Regards,
Rutuja Khalate