How to auto populate configuration item based on category and sub-category in incident form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 10:45 PM
Hi,
I need to auto populate configuration item based on the selection of category and sub category on incident form.
For example:
Category: Network
Subcategory: Switches
Configuration item: Should populate only datas from (cmdb_ci_ip_switch)
Can anyone help me in achieving this.
Thanks,
Sugand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 11:00 PM
Hello,
Please check below article, it may help you.
If my answer has helped you in any way please mark it as correct or helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 11:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 12:48 AM
Hi @sugand ,
Please follow below steps for populating CI ...
1. Navigate to *System Definition > Business Rules*.
2. Click *New*.
3. Enter the following information:
- *Name*: Populate Configuration Item
- *Table*: Incident
- *When*: After
- *Condition*: Category is not empty
- *subcategory* : subcategory is not empty
- *Script*:
```
// Get the category value
var category = current.category;
// Get the sub category value
var subCategory = current.subcategory;
// Check if the category is not empty
if (category != '') {
// Query the cmdb_ci table for CIs that have the same category
var ciQuery = new GlideRecord('cmdb_ci');
ciQuery.addQuery('category', category);
// If CI is found, then set the configuration item field
if (ciQuery.next()) {
current.configuration_item = ciQuery.sys_id;
}
}
```
4. Click **Save**.
5. Navigate to **Incident** form.
6. Select a value for **Category**.
7. The **Configuration Item** field will be auto populated with the appropriate CI.
If this is helpful for you, Please mark Helpful and Correct solution
Thanks & Regards
Adarsh Verma