- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2022 11:59 PM
Hi,
- I have two new custom field in incident table called "Start date/time" and "End date time".
- I created one UI Page that comes when we click the UI Action button in incident form.
- I have only one message textbox field in UI Page with "Save" and "Cancel" button in the form.
So when user enters any message in textbox and click the save button in UI Page, I have to do the below validation.
Check current date/time is between "Start date/time" and "End date/time".
If Yes, Popup one alert with message of "Successfully added the message in comments" and save the message into comments.
If No, Popup one alert with message of "You can't add any message, because the time is crossed".
I used the below script, but it's not worked. Please help me to fix this issue.
//UI Page Client script:-
var start = g_form.getValue("start_date_time");
var end = g_form.getValue("end_date_time");
var nowDate = new Date(); //getting current date
if(nowDate.getNumericValue() > start.getNumericValue() && nowDate.getNumericValue() < end.getNumericValue()){
// My alert message for yes
}
else{
// My alert message for no
}
Thanks,
Raj
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2022 12:30 AM
Thanks Mohith. It's worked as I expected.
I have used the below code.
var start = g_form.getValue("start_date_time");
var end = g_form.getValue("end_date_time");
var startDT = new Date(start);
var endDT = new Date(end);
var nowDate = new Date();
if (nowDate > startDT && nowDate < endDT) {
// My alert message for yes
}
else{
// My alert message for no
}
Thanks,
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2022 12:20 AM
Helllo Can you try the below code
var start=g_form.getValue("start_date_time");
var end = g_form.getValue("end_date_time");
var nowDate = new GideDateTime();
var nowStartDate = new GlideDateTime(start);
var nowEndDate = new GlideDateTime(end); if(nowDate.getDate()>nowStartDate.getDate() && nowDate.getDate() < nowEndDate.getDate())
{ // My alert message for yes
} else{ // My alert message for no
}
Mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2022 12:30 AM
Thanks Mohith. It's worked as I expected.
I have used the below code.
var start = g_form.getValue("start_date_time");
var end = g_form.getValue("end_date_time");
var startDT = new Date(start);
var endDT = new Date(end);
var nowDate = new Date();
if (nowDate > startDT && nowDate < endDT) {
// My alert message for yes
}
else{
// My alert message for no
}
Thanks,
Raj