Populate list of CI in incident when category is specific one
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 07:16 AM
Hello Experts,
Iam trying to achieve to list the particular CI's of class is computer when the category is "BitLocker".
I have written and Script include and Client script to pull the list of it(Given Below)
Im able to achieve through the logs but not in the list of the CI's.
Please help urgently.
Script include :
getCI: function() {
var retArray = [];
var relGr = new GlideRecord('cmdb_ci');
//gs.log(CIClass,'YAD');
//if(CIClass=='Bitlocker')
//{
relGr.addQuery('sys_class_name','cmdb_ci_computer');
//}
relGr.query();
while (relGr.next()) {
retArray.push(relGr.sys_id.toString());
}
return 'sys_idIN' + retArray;
},
Client script :
OnChange of category :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.getValue('category') == 'Bitlocker') {
g_form.clearOptions('cmdb_ci');
var gr = new GlideAjax('CG_ClientUtil');
gr.addParam('sysparm_name', 'getCI'); // function name in script Include
gr.getXML(getCIs);
}
function getCIs(response) {
var CIs = response.responseXML.documentElement.getAttribute("answer");
g_form.addInfoMessage(CIs);
g_form.setValue('cmdb_ci', CIs);
}
}
Please help ASAP
Looping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 07:19 AM
Hi,
your question is not clear.
Can you share complete details with screenshots?
if you wish to restrict records then you need to use advanced ref qualifier.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2023 09:16 AM
Hi Ankur,
I have similar requirement that in incident form I need to display list of records based on the category field.
Like when I select category is Application then I need to display affected ci field as cmdb_ci_application table records.
Please help me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2023 12:20 PM
Hi @msc ,
You can follow the exact same process to which I replied. But change the script include code as below,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2023 12:07 PM - edited 05-22-2023 12:19 PM
Hi @Manoj10 ,
As per my understanding, you are trying to filter the list of configuration items based on the category field. Since Configuration Item is a Reference Field you need to create an advanced Reference Qualifier.
Please find the below steps:-
1. Right-click and go to its dictionary of Configuration Item Field.
2. Go to its Dictionary Override, if there is a Dictionary Override available for your table then use it, else create one for your table(assuming the parent table is Task table of Configuration item in your case).
3. Check the Override Reference qualifier and your script include the name and function like below in the Reference Qualifier field. Script include should not be a client callable.
javascript:new TaskUtils().getCI(current); //TaskUtils is the Script Include Name and getCI is the Function name
4. Paste the below code in your script include:-
If you are not using a task extended Configuration item field then go to its Reference Specification -> Use Reference Qualifier ->Reference qual
Paste the below line.
javascript:new TaskUtils().getCI(current); //TaskUtils is the Script Include Name and getCI is the Function name
Please mark my answer as helpful and accept it as a solution, if it helps!!