wanted to forcefully capture the updates for groups related in the update set,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
hi
we wanted to forcefully capture the updates for groups related in the update set, is there any background script for it to capture updates forcefully? TIA
regards,
Siva.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
HI @Siva_Prasad ,
There are few alterative way to capture but its not good recommendation.
Background Script to Force Capture Group Updates
var updateSetId = 'INSERT_UPDATE_SET_SYS_ID_HERE'; // Replace with your update set sys_id
var gr = new GlideRecord('sys_user_group');
gr.query();
while (gr.next()) {
var tracker = new GlideRecord('sys_update_xml');
tracker.initialize();
tracker.name = gr.getTableName() + '_' + gr.getUniqueValue();
tracker.target_name = gr.getTableName();
tracker.target_table = gr.getTableName();
tracker.update_set = updateSetId;
tracker.payload = new GlideSysUpdate(gr).getXML();
tracker.insert();
}
- Replace INSERT_UPDATE_SET_SYS_ID_HERE with the Sys ID of your target update set.
- This script loops through all sys_user_group records and adds them to the update set.
- You can modify the query to filter specific groups if needed.
NOTE -
- This method can add a lot of records, so use filters if you only need specific ones.
- Always test in a sub-production instance before running in production.
Best Practice Alternatives
Instead of using background scripts to force updates:
Use Data Migration Tools:
- Export/Import XML for specific records.
- Use Transform Maps or IntegrationHub for structured data migration.
Use Scoped Applications:
- Package reference data as part of an application with version control.
Document Manual Steps:
- For static data like groups, document the creation steps and recreate them manually in target instances.
Use the sys_update_set API Carefully:
- If you must use scripts, ensure you filter records precisely and test thoroughly.
Please mark as correct and close the thread if this is helpful.
Thanks,
Rithika.ch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
suggestion -please use this method unless until its really important to capture .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
@Siva_Prasad Refer : https://www.servicenow.com/community/servicenow-ai-platform-forum/how-to-add-scheduled-job-script-in...
The answer explains other approaches as well, use the one suitable to you.