- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2024 10:36 AM
Hello, I have a CMDB Health Group and I have an associated encoded query that I want to add into an Update Set. How do you add the group with its encoded query into the update set so when transported it will be added into a new instance along with its query?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2024 12:59 PM - edited ‎10-15-2024 01:02 PM
Hi @Samuel ,
You can try write a background script (shown below) to force capture the CMDB group into the current selected update set first.
1. System Definition -> Scripts - Background
2. Add and run below code after replacing the record's sys Id.
//Query for the record
var rec = new GlideRecord('cmdb_group');
rec.get('<cmdb group's sys_id>');
//Push the record into the current update set
var um2 = new GlideUpdateManager2();
um2.saveRecord(rec);
Secondly, since it may not capture the associated encoded query which is in a different table, hence, you can write a similar background script to force capture the encoded query as well.
var rec = new GlideRecord('cmdb_group_contains_encoded_query');
rec.get('<encoded query's sys_id>');
var um2 = new GlideUpdateManager2();
um2.saveRecord(rec);
You can refer the LINK for more information regarding this force capture background script.
You can also download 'Add to update set' utility from HERE and commit the downloaded update set. After that you will should see an UI Action ('Add to update set') on every records. Just click on that and that particular record will be captured in your current update set.
However, this utility is developed by third party hence ServiceNow does not support this officially.
If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2024 11:52 AM
Hello @samuelbingham ,
To add a **CMDB Health Group** along with its associated **encoded query** into an **Update Set**, you need to follow these steps to ensure that both the group and its query are properly captured and transported to another instance. Here's how to do it:
### Steps:
1. **Create or Open the Update Set:**
- Navigate to **System Update Sets > Local Update Sets**.
- Either create a new Update Set or select an existing one where you want to capture the changes.
2. **Add the CMDB Health Group to the Update Set:**
- Go to **Configuration > CMDB Health > Health Groups**.
- Locate the specific CMDB Health Group that you want to include in the Update Set.
- Open the record for that CMDB Health Group.
- From the record form's **context menu** (the three vertical dots in the top-right corner), click **"Add to Update Set"**.
- This will add the CMDB Health Group definition into the Update Set.
3. **Capture the Encoded Query:**
- CMDB Health Groups often have associated **conditions** or **filters** stored as encoded queries.
- To ensure that the encoded query (conditions) is also included, you may need to:
- Navigate to the **Health Inclusion Rule** or **Group Filter** that is associated with this CMDB Health Group. These records store the encoded query.
- Similar to the group, open the record form for the associated inclusion rule or filter and click **"Add to Update Set"** from the context menu.
4. **Verify the Records in the Update Set:**
- After adding the CMDB Health Group and its related encoded query (filter or inclusion rule), navigate to **System Update Sets > Local Update Sets** and open your Update Set.
- Check the list of records captured in the Update Set to verify that both the CMDB Health Group and its associated filter/inclusion rule are included.
5. **Transport to New Instance:**
- Once the Update Set is complete and contains the required changes, **export** the Update Set from the source instance and **import** it into the target instance.
- After importing, commit the Update Set in the target instance.
6. **Verify in the New Instance:**
- Once the Update Set is applied in the new instance, navigate to **CMDB Health > Health Groups** to ensure that the group and its encoded query (filter/inclusion rule) are properly created and functioning.
### Additional Considerations:
- Ensure that **all associated records** (like conditions, inclusion rules, or related filters) are included in the Update Set, as missing pieces could result in incomplete functionality after the transport.
- If any **Custom Scripted Filters** are used, make sure those are also included in the Update Set.
By following this process, both the CMDB Health Group and its encoded query should be transported to the new instance seamlessly.
Best regards,
Raja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2024 12:59 PM - edited ‎10-15-2024 01:02 PM
Hi @Samuel ,
You can try write a background script (shown below) to force capture the CMDB group into the current selected update set first.
1. System Definition -> Scripts - Background
2. Add and run below code after replacing the record's sys Id.
//Query for the record
var rec = new GlideRecord('cmdb_group');
rec.get('<cmdb group's sys_id>');
//Push the record into the current update set
var um2 = new GlideUpdateManager2();
um2.saveRecord(rec);
Secondly, since it may not capture the associated encoded query which is in a different table, hence, you can write a similar background script to force capture the encoded query as well.
var rec = new GlideRecord('cmdb_group_contains_encoded_query');
rec.get('<encoded query's sys_id>');
var um2 = new GlideUpdateManager2();
um2.saveRecord(rec);
You can refer the LINK for more information regarding this force capture background script.
You can also download 'Add to update set' utility from HERE and commit the downloaded update set. After that you will should see an UI Action ('Add to update set') on every records. Just click on that and that particular record will be captured in your current update set.
However, this utility is developed by third party hence ServiceNow does not support this officially.
If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2024 01:08 PM
I appreciate this. So if I implement the second script, will the encoded query still be associated with the same CMDB group once added to the update set and transported to a new instance, or will I still have to manually add the encoded query to the cmdb group record in the new instance?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2024 01:14 PM - edited ‎10-15-2024 01:24 PM
Hi @samuelbingham ,
Yes it should be associated with the same CMDB group once added to the update set. You need to maintain the order that capture the group first and then the encoded query.
I would recommend try this once for the movement from your Dev environment to Test environment before movement to production and share with us if everything worked successfully.
I am hopeful that it should work.
If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das