please provide the solution for the following query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 11:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 01:59 PM
GlideRecord queries have this neat(?) feature where if an addQuery line is unknown/invalid it ignores it. Your addQuery is invalid because there is not a column named 'request_name' on the sc_cat_item_producer table, and you'll also need to define reqName. With GlideAjax there is not an argument passed in with the function call like you can do in a Reference qualifier, Business Rule,... so you need to define the parameter that you're passing in from the Client like this:
isRequestNameUnique: function() {
var reqName = this.getParameter('sysparm_requestName');
var gr = new GlideRecord('sc_cat_item_producer'); // Replace with the appropriate table name.
gr.addQuery('name', reqName);
gr.query();
if (gr.next()) {
return 'false'; // Not unique.
}
return 'true'; // Unique.
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 12:47 AM
Hi @Priyapatnayak ,
As you are passing the request number using glide ajax, use this.getParameter('sysparm_requestName') in the script include to purse the request number.
Updated Script Include Code:
var CheckUniqueRequestNameScriptInclude = Class.create();
CheckUniqueRequestNameScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isRequestNameUnique: function() {
var gr = new GlideRecord('sc_cat_item_producer'); // Replace with the appropriate table name.
// Updated Line
gr.addQuery('request_name', this.getParameter('sysparm_requestName'));
gr.query();
if (gr.next()) {
return 'false'; // Not unique.
}
return 'true'; // Unique.
}
});