- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 07:32 AM
Hello, I am trying to query with catalog item variables while gliding RITM table. My goal is to use script include to perform a query using the variable - firstname and value retrieved from newValue (Client Script) in variable itself before being submitted as requested item. Therefore, an alert returns when I change the field (firstname) with data that is already submitted. The issue is that it seems to not be working when I query the following way the RITM table for the variables.
The variables.sysid (retrieved from RITM table). I think the issue might be there, but could not really make sense of it.
Also, another option I thought would work is current.variables.firstname.
var UserExists = Class.create();
UserExists.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkUserExists: function() {
//var user_id = this.getParameter('username'); //get the value from client script
var gr = new GlideRecord('sc_req_item');
gr.addQuery('variables.47c6ee9047a11110bfc57868f36d43b6I',this.getParameter('sysparm_firstname')),
//
//gr.addQuery('variables.5fa6ae5047a11110bfc57868f36d4314=andihoxha', this.getParameter('sysparm_username'));
// gr.addEncodedQuery('variables.5fa6ae5047a11110bfc57868f36d4314=andihoxha');
//gr.addQuery()
gr.query();
if (gr.next()) {
return true;
} else {
return false;
}
},
type: 'UserExists'
});
Client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('UserExists'); // Ajax call
ga.addParam('sysparm_name', 'checkUserExists'); //method from sclipt include which is used to add parameters
ga.addParam('sysparm_firstname', newValue);
ga.getXML(callScriptInclude); //callback the Script include
function callScriptInclude(response) {
var answer = response.responseXML.documentElement.getAttribute("answer"); //response return from Script Include
if (answer == 'true') {
alert('123');
}
}
//Type appropriate comment here, and begin script below
}
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 07:55 AM
Hi Andi,
I think "variables.47c6ee9047a11110bfc57868f36d43b6I" contains an extra character which is I at the end.
So try replacing
gr.addQuery('variables.47c6ee9047a11110bfc57868f36d43b6I',this.getParameter('sysparm_firstname')),
With
gr.addQuery('variables.47c6ee9047a11110bfc57868f36d43b6',this.getParameter('sysparm_firstname')),
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 07:55 AM
Hi Andi,
I think "variables.47c6ee9047a11110bfc57868f36d43b6I" contains an extra character which is I at the end.
So try replacing
gr.addQuery('variables.47c6ee9047a11110bfc57868f36d43b6I',this.getParameter('sysparm_firstname')),
With
gr.addQuery('variables.47c6ee9047a11110bfc57868f36d43b6',this.getParameter('sysparm_firstname')),
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 08:21 AM
Thank you, it appears this tiny thing made the whole annoying for nothing.
