How to glide record a table using Glide Ajax call ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 10:59 AM
Hi Team,
I have a requirement, Where I need to query a table by using value's entered in List Collector variable.
I need to query cmdb_ci table and need to get the data regarding all values entered in the list collector.
This should be a glide ajax call.
any guidance will help me a lot.
Thanks,
AB.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 11:08 AM
Hi Abhay,
Check below link for understanding glideajax.
You need to pass the list collector value to the glideajax function. it will be a list of comma separated list collector.
You need to split them and query the cmdb_ci table using GlideRecord.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 11:26 AM
Sample Code,modify according to your requirement.
Check 3.2 Section
Client Script Best Practices - ServiceNow Wiki
3.2 Example: Asynchronous GlideAjax
This script compares the support group of the CI and the assignment group of the incident by name:
//Alert if the assignment groups name matches the support group function onChange(control, oldValue, newValue, isLoading) { if (isLoading) return; var ga = new GlideAjax('ciCheck'); ga.addParam('sysparm_name', 'getCiSupportGroup'); ga.addParam('sysparm_ci', g_form.getValue('cmdb_ci')); ga.addParam('sysparm_ag', g_form.getValue('assignment_group')); ga.getXML(doAlert); // Always try to use asynchronous (getXML) calls rather than synchronous (getXMLWait) } // Callback function to process the response returned from the server function doAlert(response) { var answer = response.responseXML.documentElement.getAttribute("answer"); alert(answer); }
This script relies on an accompanying script include, such as:
var ciCheck = Class.create(); ciCheck.prototype = Object.extendsObject(AbstractAjaxProcessor, { getCiSupportGroup: function() { var retVal = ''; // Return value var ciID = this.getParameter('sysparm_ci'); var agID = this.getParameter('sysparm_ag'); var ciRec = new GlideRecord('cmdb_ci'); // If we can read the record, check if the sys_ids match if (ciRec.get(ciID)) { if (ciRec.getValue('support_group') == agID) retVal = 'CI support group and assignment group match'; else retVal = 'CI support group and assignment group do not match'; // Can't read the CI, then they don't match } else { retVal = 'CI support group and assignment group do not match'; } return retVal; } });