In UI page code doesn't work different instance environments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2023 04:20 AM
UI Page code works on my PDI, but doesn't work in my company instance and I don't receive expected output. Can anyone help me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2023 05:54 AM - edited ‎12-02-2023 06:00 AM
By using the UI action button, particular role users can change into past dates for change requests, i.e. planned start and end dates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2023 06:34 AM
what's your business requirement to use UI page?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-02-2023 11:06 PM
When user clicks ui action button inside UI pages fields created are there i.e , Planned start date , Planned end date and reason.
particular role users can change into past dates for change requests, i.e. planned start and end dates .
it's working on properly my PDI but doesn't work on my company instance
How to fix this one
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2023 07:27 AM
HI @Anish9515 ,
I trust you are doing great.
Please find the updated code. :
function onSubmit() {
var startDateInput = document.getElementById("date");
var endDateInput = document.getElementById("date1");
var errorElement = document.getElementById("error-message");
var startDateStr = startDateInput.value;
alert("The start date is " + startDateStr);
if (startDateStr === '') {
errorElement.textContent = "Please select the planned start date";
errorElement.style.display = "block";
return false;
}
var endDateStr = endDateInput.value;
alert("The end date is " + endDateStr);
if (endDateStr === '') {
errorElement.textContent = "Please select the planned end date";
errorElement.style.display = "block";
return false;
}
var comments = document.getElementById("info").value.trim();
if (comments === "") {
errorElement.textContent = "Reason to set the date in the past";
errorElement.style.display = "block";
return false;
}
// Convert user date strings to Date objects for comparison
var startDate = new Date(startDateStr);
var endDate = new Date(endDateStr);
var currentDate = new Date(); // Current date and time
// Formatting the current date to match the user date format (if necessary)
// Assuming g_user_date_format includes both date and time
var currentDateFormatted = formatDate(currentDate, g_user_date_time_format);
alert("The current date is " + currentDateFormatted);
// Comparing dates
if(startDate > currentDate) {
errorElement.textContent = "The Planned start date cannot be in the future";
errorElement.style.display = "block";
return false;
}
if(endDate < startDate) {
errorElement.textContent = "Planned end date must be after planned start date";
errorElement.style.display = "block";
return false;
}
return true;
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2023 04:31 PM
My adjustment code is working fine in my PDI
But same code doesn't work on my company instances
I guess "current date" is an issue