Filter CIs on record producer form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 06:20 AM
Hi All,
In our instance, on the incident form the configuration is filtered based on category and subcategory.
Below is the screenshot of dictionary override entry of configuration item field for incident table. Here, it is checking the script include "cat_subcatCI_INC()".
Script include: In this script it is checking a custom table "CI Categorizations" where will have category, subcategory and CI tables. Please find the below reference screenshot.
function cat_subcatCI_INC(){
var configitems = []; // array of group sys_ids to return to the calling reference qualifier
if (!current.category.nil()) {
var category = current.category;
var subcat=current.subcategory;// from the task form
var gr = new GlideRecord('u_ci_categories_subcategoreis'); //Where CI to group relationship is store.
gr.addQuery('u_category', category);
gr.addQuery('u_subcategory',subcat);
gr.query();
if (gr.hasNext()) {
while (gr.next()) {
gs.log('Table Nameeeee is:'+gr.u_ci_table);
var id=gr.u_ci_table;
var arr=id.split(',');
for(i=0;i<arr.length;i++){
var gt=new GlideRecord('sys_db_object');
gt.get(arr[i]);
configitems.push(gt.name);
}
}
gs.log('configItems are:'+configitems);
return 'sys_class_nameIN' + configitems.join(',')+'^operational_status!='+2+'^operational_status!='+10;
}
}
}
So, now the requirement is to implement same for a record producer. I have created the 3 variables category, subcategory and configuration item on the record producer form where user raise a request when there is an issue. But how to implement this logic, how to call this script include client side or do we need to create a new script include?
Can we do it through a script include and a client script? Please assist.
Thanks & Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 11:02 AM
Hi @Joshuu ,
On your Record Producer , you can achieve this through onChange Client Script written on field <subcategory> provided the category is selected from your client script you can pass two values[cat and subcat] to your script include and return the list of sys_ids of the CIs and then populate the field on your record producer . Or you can create a reference qualifier on your CI field on record producer and then call your script include directly by passing the two values of cat and subcat but in your case the SI on INC is without parameters so I think you may need to duplicate the SI and add two parameters to the function call.
Please mark correct/helpful if my response helped you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 11:07 AM
Hi @Anubhav24 ,
Could you please help me with on change client script and script include.
Please assist.
Thanks & Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 11:13 AM
Hi @Joshuu ,
You can refer to below developer article to create your own Client Script and Script Include.
Please mark helpful/correct if my response helped you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 11:15 AM - edited 02-29-2024 11:16 AM
Hi @Anubhav24 ,
I know this article. But I am stuck at client script. I am not getting how to filter cis. Do we need to use setvalue?
Because here I want to show cis based on the subcategory. It is not just a value to set.
Please help.
