Glide Record not found for hasNext
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2025 05:44 AM
My requirements are to query the Incident table on submit from the portal to identify any potential similar issues at the same location; alert the user they may be creating a duplicate record; and confirm they want to proceed with opening the new Incident. Using the below script in a Catalog Client Script, however, I do not get the expected confirmation window. I even commented out the query for the custom location field and tried to pull results for any Incidents in an open status. Still, I get no confirmation window. Is there something I'm missing from the below code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2025 05:53 AM
using GlideRecord in client side is not recommended.
why not have onChange catalog client script on Location and throw error if validation fails?
With this you ensure correct location is selected
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
‎02-23-2025 04:07 AM
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
‎02-21-2025 06:01 AM
Don't use GlideRecord on client side, Use client callable script include and client script.
Script Inlcude:
var CheckDuplicateIncident = Class.create();
CheckDuplicateIncident.prototype = {
initialize: function() {},
checkDuplicate: function(location) {
var result = false;
var incidentGr = new GlideRecord('incident');
incidentGr.addQuery('u_property_location', location); // Replace with the actual field name
incidentGr.addQuery('state', 'IN', '1,2,3'); // Checking Open status incidents
incidentGr.query();
if (incidentGr.hasNext()) {
result = true; // Duplicate found
}
return result;
},
type: 'CheckDuplicateIncident'
};
Client script:
function onSubmit() {
var location = g_form.getValue('location'); // Replace 'location' with the actual variable name
if (location) {
var ga = new GlideAjax('CheckDuplicateIncident'); // Call the Script Include
ga.addParam('sysparm_name', 'checkDuplicate');
ga.addParam('sysparm_location', location);
ga.getXMLAnswer(function(response) {
if (response == 'true') {
var confirmMessage = confirm("There is already a ticket open for this location. Do you want to proceed with opening this ticket?");
if (!confirmMessage) {
g_form.clearMessages();
g_form.addErrorMessage("Submission canceled due to potential duplicate.");
g_form.submit(false);
}
}
});
}
}
Please mark correct/helpful if this helps you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2025 10:27 AM
Giga,
Thank you for your suggestion. When I tried executing your scripts, I am not seeing the expected confirmation window though there are several Incidents currently in an open status with the same location as the one selected. Any recommendations on what to check?