trying to builup a catalog item using script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2024 02:29 AM
trying to buildup a catalog item using script include where when user put the value for example "serial number" it will give the error that serial number is already exist writing client callable script but stuck to build up a logic any help ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2024 02:44 AM
Try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
try {
var ajax = new GlideAjax('<script include>');
ajax.addParam('sysparm_name', '<function name>');
ajax.addParam('sysparm_rec_name', newValue);
ajax.getXMLAnswer(function(answer) {
if (answer == true) {
//clear value
//throw error
}
});
} catch (e) {
alert(e.message);
}
}
Script Include:
var <SCript include NAme>= Class.create();
<SCript include NAme>.prototype = Object.extendsObject(AbstractAjaxProcessor, {
<function NAme>: function() {
var groupName = this.getParameter('sysparm_re_name');
var grGroup = new GlideRecord('<table>');
if (grGroup.get('name', groupName)) {
return true;
}
return false;
},
type: 'GroupUtil'
});
Use correct script include, table and function names
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2024 04:37 AM - edited ‎09-06-2024 05:05 AM
in script include what is 'name ' indicating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2024 05:19 AM - edited ‎09-06-2024 05:20 AM
You need to give the script a name
It could be anything like CalaogItemSupportUtil
The name in line below is just indicative, you need to build that query based on your logic whatever way you identify whether record exists or not
if (grGroup.get('name', groupName)) {