- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2025 10:27 AM
this is my catlog item and table . i need block the user from submitting the catlog item if the there is same room with same start and end date is already present in the table .. some one pls give me entire code . i have tried for 2 days but still not working
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2025 12:17 AM
remember these points:
1) Asynchronous GlideAjax won't work as by the time ajax function returns the value your form will get submitted
2) Synchronous GlideAjax is not allowed in portal and scoped application
Approach: Please use onChange catalog client script on Start and End and then use GlideAjax, if validation fails then show error message on that variable
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2025 12:07 AM
Hello @SIVAKARTHICS,
Can you please attach your screenshots again?
As there is some problem going on in the community.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2025 12:17 AM
remember these points:
1) Asynchronous GlideAjax won't work as by the time ajax function returns the value your form will get submitted
2) Synchronous GlideAjax is not allowed in portal and scoped application
Approach: Please use onChange catalog client script on Start and End and then use GlideAjax, if validation fails then show error message on that variable
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2025 07:39 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2025 01:13 AM - edited ‎07-29-2025 01:16 AM
Hello @SIVAKARTHICS
Please understand the Technical Glitch here:
User is going to select the date from the Browser, and you are about to compare the date which is already there in tables record.
when you pass the date from client script to server, system do not have any provision to compare with it as it uses server's date and time using available APIs.
I am Providing you sample code :
Client Script : on Submit, based on your field add appropriate field
if you do this using on Change, then You need to write 2 client script for 2 variable. here you can use g_form.clearValue() and g_form.showFieldMsg
var room = g_form.getValue(''); // add your field name
var startDate = g_form.getValue('start_date'); // Replace with your field name
var endDate = g_form.getValue('end_date'); // Replace with your field name
// Call server-side GlideAjax
var ga = new GlideAjax('RoomBooking');
ga.addParam('sysparm_name', 'checkRoomAvailability');
ga.addParam('sysparm_room', room);
ga.addParam('sysparm_start_date', startDate);
ga.addParam('sysparm_end_date', endDate);
var result = ga.getXMLWait();
var answer = ga.getAnswer();
if (answer === 'true') {
g_form.showFieldMsg('room', 'This room is already booked for the selected date range.', 'error');
return false;
}
return true;
}
Script Include:
var RoomBooking = Class.create();
RoomBooking.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkRoomAvailability: function() {
var room = this.getParameter('sysparm_room');
var startDate = this.getParameter('sysparm_start_date');
var endDate = this.getParameter('sysparm_end_date');
var gr = new GlideRecord(''); // add your table name
gr.addQuery('room', room);
gr.addQuery('start_date', startDate);
gr.addQuery('end_date', endDate);
gr.query();
if (gr.hasNext()) {
return 'true'; // Conflict exists
}
return 'false'; // No conflict
}
});
I hope, this might help you
Thanks and Regards
Gaurav Shirsat