- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2025 08:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Is issue still open @munukuntlak
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @munukuntlak
- Log in to Webassessor using your credentials.
- Go to My Profile or Account Settings.
- Update your name to the desired format (full name, initials, etc.).
- Save the changes.
If the certificate has already been issued, you may need to contact Webassessor support or the certifying organization to request a reissue with the corrected name.
Would you like me to provide:
- A step-by-step guide for updating your Webassessor profile?
- Or the contact details for Webassessor support?
If anymore issue please do raise a ticket with servicenow
If my response proves useful, please do " Accept as Solution" and " Helpful." This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Is issue still open @munukuntlak
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
var requestType = g_form.getValue('request_type');
var server = g_form.getValue('server');
console.log('=== Maintenance Schedule Type Changed ===');
console.log('Request Type: ' + requestType);
console.log('Schedule Type: ' + newValue);
console.log('Server: ' + server);
// Always hide schedule_name_ref
g_form.setDisplay('schedule_name_ref', false);
// If no schedule type selected, clear and hide all fields
if (!newValue || newValue == '') {
clearAndHideAllFields();
return;
}
// Validate server is selected
if (!server) {
g_form.addErrorMessage('Please select a Server first');
g_form.clearValue('maintenance_schedule_type');
return;
}
// Call AJAX to get schedule details
var ga = new GlideAjax('SLAMCatalogUtils');
ga.addParam('sysparm_name', 'getScheduleDetailsForCatalog');
ga.addParam('sysparm_schedule_type', newValue);
ga.addParam('sysparm_server', server);
ga.addParam('sysparm_request_type', requestType);
ga.getXMLAnswer(function(answer) {
if (!answer) {
g_form.addErrorMessage('Unable to retrieve schedule details');
// Still show fields even if AJAX fails
handleNoScheduleFound();
return;
}
try {
var results = JSON.parse(answer);
console.log('Schedule Details Retrieved:', results);
if (results.error) {
// M2M record doesn't exist - show fields anyway
console.log('No M2M record found: ' + results.error);
g_form.addInfoMessage('No existing schedule found. You can create a new one.');
handleNoScheduleFound();
return;
}
// Store schedule_sys_id in a hidden field for reference qualifier
if (results.schedule_sys_id) {
g_form.setValue('hidden_schedule_sys_id', results.schedule_sys_id);
}
if (requestType == 'add_window') {
handleAddWindow(results);
} else if (requestType == 'update_window') {
handleUpdateWindow(results);
}
// Make end_time read-only
g_form.setReadOnly('end_time', true);
} catch (e) {
console.error('Error parsing response:', e);
g_form.addErrorMessage('Error processing schedule details');
// Still show fields even if parsing fails
handleNoScheduleFound();
}
});
// ===== HELPER FUNCTIONS =====
function handleNoScheduleFound() {
console.log('Handling No Schedule Found - Showing fields anyway');
if (requestType == 'add_window') {
// Show fields for adding new window even without existing schedule
// Don't populate schedule_name - let user see it's empty
g_form.clearValue('schedule_name');
g_form.setReadOnly('schedule_name', false);
g_form.setDisplay('schedule_name', true);
g_form.setMandatory('schedule_name', true);
// Show entry details as empty
g_form.setValue('schedule_entry_details', 'No existing schedule found. This will create a new schedule.');
g_form.setReadOnly('schedule_entry_details', true);
g_form.setDisplay('schedule_entry_details', true);
// Hide schedule entry
g_form.setDisplay('schedule_entry', false);
g_form.setMandatory('schedule_entry', false);
g_form.clearValue('schedule_entry');
// Show time zone
g_form.setDisplay('time_zone', true);
g_form.setMandatory('time_zone', true);
g_form.setReadOnly('time_zone', false);
// Set repeat on to weekly
setRepeatOnToWeekly();
// Show all other fields
showFieldsForAdd();
// Clear any pre-filled data
clearEntrySpecificFields();
g_form.addInfoMessage('Fill in the new maintenance window details below');
} else if (requestType == 'update_window') {
// For update without M2M - show error but allow user to proceed
g_form.addErrorMessage('No existing schedule found. Please use Add Window instead.');
clearAndHideAllFields();
}
}
function handleAddWindow(data) {
console.log('Handling Add Window');
// Set Schedule Name (read-only if exists, editable if new)
if (data.schedule_name) {
g_form.setValue('schedule_name', data.schedule_name);
g_form.setReadOnly('schedule_name', true);
g_form.setDisplay('schedule_name', true);
} else {
g_form.clearValue('schedule_name');
g_form.setReadOnly('schedule_name', false);
g_form.setDisplay('schedule_name', true);
g_form.setMandatory('schedule_name', true);
}
// Set Schedule Entry Details (read-only) - Shows existing entries for reference
if (data.schedule_entry_text) {
g_form.setValue('schedule_entry_details', data.schedule_entry_text);
g_form.setReadOnly('schedule_entry_details', true);
g_form.setDisplay('schedule_entry_details', true);
}
// Hide Schedule Entry dropdown (not needed for add)
g_form.setDisplay('schedule_entry', false);
g_form.setMandatory('schedule_entry', false);
g_form.clearValue('schedule_entry');
// Set Time Zone (mandatory)
if (data.time_zone) {
g_form.setValue('time_zone', data.time_zone);
}
g_form.setMandatory('time_zone', true);
g_form.setDisplay('time_zone', true);
g_form.setReadOnly('time_zone', false);
// Set Repeat On to Weekly (read-only)
setRepeatOnToWeekly();
// Show and make mandatory: Description, Start Time, End Time, Days, Justification
showFieldsForAdd();
// Clear any pre-filled data
clearEntrySpecificFields();
g_form.addInfoMessage('Fill in the new maintenance window details below');
}
function handleUpdateWindow(data) {
console.log('Handling Update Window');
// Set Schedule Name (read-only)
if (data.schedule_name) {
g_form.setValue('schedule_name', data.schedule_name);
g_form.setReadOnly('schedule_name', true);
g_form.setDisplay('schedule_name', true);
}
// Set Schedule Entry Details (read-only) - Shows all entries as reference
if (data.schedule_entry_text) {
g_form.setValue('schedule_entry_details', data.schedule_entry_text);
g_form.setReadOnly('schedule_entry_details', true);
g_form.setDisplay('schedule_entry_details', true);
}
// Show Schedule Entry dropdown (mandatory) - filtered by schedule
g_form.setDisplay('schedule_entry', true);
g_form.setMandatory('schedule_entry', true);
g_form.clearValue('schedule_entry');
// Set Time Zone
if (data.time_zone) {
g_form.setValue('time_zone', data.time_zone);
}
g_form.setMandatory('time_zone', true);
g_form.setDisplay('time_zone', true);
g_form.setReadOnly('time_zone', false);
// Set Repeat On to Weekly (read-only)
setRepeatOnToWeekly();
// Show all fields for update
showFieldsForUpdate();
// Clear fields until user selects an entry
clearEntrySpecificFields();
g_form.addInfoMessage('Select a Schedule Entry from the dropdown to update');
}
function setRepeatOnToWeekly() {
console.log('Setting Repeat On to Weekly');
// Show the field
g_form.setDisplay('repeat_on', true);
// Set value to 'weekly'
g_form.setValue('repeat_on', 'weekly');
// Make it read-only
g_form.setReadOnly('repeat_on', true);
console.log('Repeat On set to weekly (read-only)');
}
function showFieldsForAdd() {
console.log('Showing fields for Add Window');
// Show and make mandatory
var fields = [
{name: 'description', mandatory: true, readonly: false},
{name: 'time_zone', mandatory: true, readonly: false},
{name: 'start_time', mandatory: true, readonly: false},
{name: 'end_time', mandatory: true, readonly: true}, // auto-calculated
{name: 'repeat_on', mandatory: false, readonly: true}, // set to weekly
{name: 'select_days_of_the_week', mandatory: false, readonly: false},
{name: 'justification', mandatory: true, readonly: false}
];
fields.forEach(function(field) {
g_form.setDisplay(field.name, true);
g_form.setMandatory(field.name, field.mandatory);
g_form.setReadOnly(field.name, field.readonly);
});
// Show day checkboxes
var days = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
days.forEach(function(day) {
g_form.setDisplay(day, true);
});
}
function showFieldsForUpdate() {
console.log('Showing fields for Update Window');
// Same as add
showFieldsForAdd();
}
function clearEntrySpecificFields() {
console.log('Clearing entry specific fields');
g_form.clearValue('description');
g_form.clearValue('start_time');
g_form.clearValue('end_time');
g_form.clearValue('justification');
// Clear day checkboxes
var days = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
days.forEach(function(day) {
g_form.setValue(day, false);
});
console.log('Fields cleared');
}
function clearAndHideAllFields() {
console.log('Clearing and hiding all fields');
var allFields = [
'schedule_name',
'schedule_entry_details',
'schedule_entry',
'description',
'time_zone',
'start_time',
'end_time',
'repeat_on',
'select_days_of_the_week',
'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun',
'justification'
];
allFields.forEach(function(field) {
g_form.clearValue(field);
g_form.setDisplay(field, false);
g_form.setMandatory(field, false);
g_form.setReadOnly(field, false);
});
// Always hide schedule_name_ref
g_form.setDisplay('schedule_name_ref', false);
console.log('All fields cleared and hidden');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday - last edited Sunday
// Background Script - Add Catalog Item to Update Set
// Using GlideUpdateManager2 (CORRECT METHOD)
(function() {
// CONFIGURATION - Change these values
var catalogItemSysId = 'YOUR_CATALOG_ITEM_SYS_ID'; // or use name
var catalogItemName = ''; // Alternative: use name instead of sys_id
var updateSetName = 'YOUR_UPDATE_SET_NAME'; // Specify your update set name
// Find the Update Set by name
var updateSetGR = new GlideRecord('sys_update_set');
updateSetGR.addQuery('name', updateSetName);
updateSetGR.addQuery('state', 'in progress');
updateSetGR.query();
if (!updateSetGR.next()) {
gs.error('Update Set not found or not in progress: ' + updateSetName);
return;
}
var updateSetId = updateSetGR.sys_id.toString();
gs.info('Using Update Set: ' + updateSetGR.name + ' (' + updateSetId + ')');
// Set this as the current update set for the session
gs.setCurrentUpdateSetId(updateSetId);
// Find catalog item
var catItem = new GlideRecord('sc_cat_item');
if (catalogItemSysId) {
catItem.get(catalogItemSysId);
} else if (catalogItemName) {
catItem.get('name', catalogItemName);
}
if (!catItem.isValidRecord()) {
gs.error('Catalog Item not found!');
return;
}
gs.info('Processing Catalog Item: ' + catItem.getDisplayValue());
// CORRECT Function to add record to update set
function addToUpdateSet(tableName, sysId) {
try {
var rec = new GlideRecord(tableName);
if (rec.get(sysId)) {
var um = new GlideUpdateManager2();
um.saveRecord(rec);
gs.info('✓ Added: ' + tableName + ' - ' + rec.getDisplayValue());
return true;
}
} catch (e) {
gs.error('Error adding ' + tableName + ': ' + e);
}
return false;
}
// 1. Add the Catalog Item itself
addToUpdateSet('sc_cat_item', catItem.sys_id);
// 2. Add Catalog Assignment (sc_cat_item_catalog)
var catalogAssignments = new GlideRecord('sc_cat_item_catalog');
catalogAssignments.addQuery('sc_cat_item', catItem.sys_id);
catalogAssignments.query();
gs.info('Found ' + catalogAssignments.getRowCount() + ' catalog assignments');
while (catalogAssignments.next()) {
addToUpdateSet('sc_cat_item_catalog', catalogAssignments.sys_id);
}
// 3. Add Catalog Item Variables
var variables = new GlideRecord('item_option_new');
variables.addQuery('cat_item', catItem.sys_id);
variables.query();
gs.info('Found ' + variables.getRowCount() + ' variables');
while (variables.next()) {
addToUpdateSet('item_option_new', variables.sys_id);
}
// 4. Add Variable Sets (if any)
var varSets = new GlideRecord('io_set_item');
varSets.addQuery('sc_cat_item', catItem.sys_id);
varSets.query();
while (varSets.next()) {
addToUpdateSet('io_set_item', varSets.sys_id);
// Add the variable set itself
if (varSets.variable_set) {
addToUpdateSet('item_option_new_set', varSets.variable_set);
// Add variables within the set
var setVars = new GlideRecord('item_option_new');
setVars.addQuery('variable_set', varSets.variable_set);
setVars.query();
while (setVars.next()) {
addToUpdateSet('item_option_new', setVars.sys_id);
}
}
}
// 5. Add Catalog UI Policies
var uiPolicies = new GlideRecord('catalog_ui_policy');
uiPolicies.addQuery('catalog_item', catItem.sys_id);
uiPolicies.query();
gs.info('Found ' + uiPolicies.getRowCount() + ' UI Policies');
while (uiPolicies.next()) {
addToUpdateSet('catalog_ui_policy', uiPolicies.sys_id);
// Add UI Policy Actions
var uiActions = new GlideRecord('catalog_ui_policy_action');
uiActions.addQuery('ui_policy', uiPolicies.sys_id);
uiActions.query();
while (uiActions.next()) {
addToUpdateSet('catalog_ui_policy_action', uiActions.sys_id);
}
}
// 6. Add Catalog Client Scripts
var clientScripts = new GlideRecord('catalog_script_client');
clientScripts.addQuery('cat_item', catItem.sys_id);
clientScripts.query();
gs.info('Found ' + clientScripts.getRowCount() + ' Client Scripts');
while (clientScripts.next()) {
addToUpdateSet('catalog_script_client', clientScripts.sys_id);
}
// 7. Add Flow Designer Flow (if attached)
if (catItem.flow_designer_flow) {
gs.info('Found Flow Designer Flow');
addToUpdateSet('sys_hub_flow', catItem.flow_designer_flow);
// Add Flow Actions
var flowActions = new GlideRecord('sys_hub_action_instance');
flowActions.addQuery('flow', catItem.flow_designer_flow);
flowActions.query();
gs.info('Found ' + flowActions.getRowCount() + ' flow actions');
while (flowActions.next()) {
addToUpdateSet('sys_hub_action_instance', flowActions.sys_id);
}
// Add Flow Variables
var flowVars = new GlideRecord('sys_variable_value');
flowVars.addQuery('document', catItem.flow_designer_flow);
flowVars.addQuery('document_key', 'sys_hub_flow');
flowVars.query();
while (flowVars.next()) {
addToUpdateSet('sys_variable_value', flowVars.sys_id);
}
// Add Flow Triggers
var flowTriggers = new GlideRecord('sys_hub_flow_trigger');
flowTriggers.addQuery('flow', catItem.flow_designer_flow);
flowTriggers.query();
while (flowTriggers.next()) {
addToUpdateSet('sys_hub_flow_trigger', flowTriggers.sys_id);
}
}
// 8. Add Catalog Categories relationship
var categories = new GlideRecord('sc_cat_item_category');
categories.addQuery('sc_cat_item', catItem.sys_id);
categories.query();
gs.info('Found ' + categories.getRowCount() + ' category assignments');
while (categories.next()) {
addToUpdateSet('sc_cat_item_category', categories.sys_id);
}
// 9. Add Record Producers (if it's a record producer)
if (catItem.sys_class_name == 'sc_cat_item_producer') {
var producer = new GlideRecord('sc_cat_item_producer');
if (producer.get(catItem.sys_id)) {
addToUpdateSet('sc_cat_item_producer', producer.sys_id);
}
}
// 10. Add Execution Plans (if any)
var execPlans = new GlideRecord('sc_ic_item_staging');
execPlans.addQuery('cat_item', catItem.sys_id);
execPlans.query();
while (execPlans.next()) {
addToUpdateSet('sc_ic_item_staging', execPlans.sys_id);
}
// 11. Add Catalog Item Tasks / Delivery Plans
var tasks = new GlideRecord('sc_cat_item_delivery_plan');
tasks.addQuery('sc_cat_item', catItem.sys_id);
tasks.query();
while (tasks.next()) {
addToUpdateSet('sc_cat_item_delivery_plan', tasks.sys_id);
}
// 12. Add Variable Choices (for choice lists)
var choices = new GlideRecord('question_choice');
choices.addQuery('question.cat_item', catItem.sys_id);
choices.query();
gs.info('Found ' + choices.getRowCount() + ' variable choices');
while (choices.next()) {
addToUpdateSet('question_choice', choices.sys_id);
}
// 13. Add Legacy Workflow (if attached)
if (catItem.workflow) {
gs.info('Found Legacy Workflow');
addToUpdateSet('wf_workflow', catItem.workflow);
var wfActivities = new GlideRecord('wf_activity');
wfActivities.addQuery('workflow', catItem.workflow);
wfActivities.query();
while (wfActivities.next()) {
addToUpdateSet('wf_activity', wfActivities.sys_id);
}
}
gs.info('===== COMPLETED =====');
gs.info('All catalog item components added to update set: ' + updateSetName);
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
// Background Script to add Catalog Item and all related records to Update Set
// Including Flow Designer support
(function() {
// CONFIGURATION - Change these values
var catalogItemSysId = 'YOUR_CATALOG_ITEM_SYS_ID'; // or use name
var catalogItemName = ''; // Alternative: use name instead of sys_id
// Get current update set
var updateSet = new GlideUpdateSet();
var currentUpdateSetId = updateSet.get();
if (!currentUpdateSetId) {
gs.error('No active update set found!');
return;
}
gs.info('Adding records to Update Set: ' + updateSet.getUpdateSetName());
// Find catalog item
var catItem = new GlideRecord('sc_cat_item');
if (catalogItemSysId) {
catItem.get(catalogItemSysId);
} else if (catalogItemName) {
catItem.get('name', catalogItemName);
}
if (!catItem.isValidRecord()) {
gs.error('Catalog Item not found!');
return;
}
gs.info('Processing Catalog Item: ' + catItem.getDisplayValue());
// Function to add record to update set
function addToUpdateSet(tableName, sysId) {
var rec = new GlideRecord(tableName);
if (rec.get(sysId)) {
var um = new GlideUpdateManager2();
um.saveRecord(rec);
gs.info('Added to update set: ' + tableName + ' - ' + rec.getDisplayValue());
return true;
}
return false;
}
// 1. Add the Catalog Item itself
addToUpdateSet('sc_cat_item', catItem.sys_id);
// 2. Add Catalog Assignment (sc_cat_item_catalog)
var catalogAssignments = new GlideRecord('sc_cat_item_catalog');
catalogAssignments.addQuery('sc_cat_item', catItem.sys_id);
catalogAssignments.query();
gs.info('Found ' + catalogAssignments.getRowCount() + ' catalog assignments');
while (catalogAssignments.next()) {
addToUpdateSet('sc_cat_item_catalog', catalogAssignments.sys_id);
}
// 3. Add Catalog Item Variables
var variables = new GlideRecord('item_option_new');
variables.addQuery('cat_item', catItem.sys_id);
variables.query();
gs.info('Found ' + variables.getRowCount() + ' variables');
while (variables.next()) {
addToUpdateSet('item_option_new', variables.sys_id);
}
// 4. Add Variable Sets (if any)
var varSets = new GlideRecord('io_set_item');
varSets.addQuery('sc_cat_item', catItem.sys_id);
varSets.query();
while (varSets.next()) {
addToUpdateSet('io_set_item', varSets.sys_id);
// Add the variable set itself
if (varSets.variable_set) {
addToUpdateSet('item_option_new_set', varSets.variable_set);
// Add variables within the set
var setVars = new GlideRecord('item_option_new');
setVars.addQuery('variable_set', varSets.variable_set);
setVars.query();
while (setVars.next()) {
addToUpdateSet('item_option_new', setVars.sys_id);
}
}
}
// 5. Add Catalog UI Policies
var uiPolicies = new GlideRecord('catalog_ui_policy');
uiPolicies.addQuery('catalog_item', catItem.sys_id);
uiPolicies.query();
gs.info('Found ' + uiPolicies.getRowCount() + ' UI Policies');
while (uiPolicies.next()) {
addToUpdateSet('catalog_ui_policy', uiPolicies.sys_id);
// Add UI Policy Actions
var uiActions = new GlideRecord('catalog_ui_policy_action');
uiActions.addQuery('ui_policy', uiPolicies.sys_id);
uiActions.query();
while (uiActions.next()) {
addToUpdateSet('catalog_ui_policy_action', uiActions.sys_id);
}
}
// 6. Add Catalog Client Scripts
var clientScripts = new GlideRecord('catalog_script_client');
clientScripts.addQuery('cat_item', catItem.sys_id);
clientScripts.query();
gs.info('Found ' + clientScripts.getRowCount() + ' Client Scripts');
while (clientScripts.next()) {
addToUpdateSet('catalog_script_client', clientScripts.sys_id);
}
// 7. Add Flow Designer Flow (if attached)
if (catItem.flow_designer_flow) {
gs.info('Found Flow Designer Flow');
addToUpdateSet('sys_hub_flow', catItem.flow_designer_flow);
// Add Flow Actions
var flowActions = new GlideRecord('sys_hub_action_instance');
flowActions.addQuery('flow', catItem.flow_designer_flow);
flowActions.query();
gs.info('Found ' + flowActions.getRowCount() + ' flow actions');
while (flowActions.next()) {
addToUpdateSet('sys_hub_action_instance', flowActions.sys_id);
}
// Add Flow Variables
var flowVars = new GlideRecord('sys_variable_value');
flowVars.addQuery('document', catItem.flow_designer_flow);
flowVars.addQuery('document_key', 'sys_hub_flow');
flowVars.query();
while (flowVars.next()) {
addToUpdateSet('sys_variable_value', flowVars.sys_id);
}
// Add Flow Triggers
var flowTriggers = new GlideRecord('sys_hub_flow_trigger');
flowTriggers.addQuery('flow', catItem.flow_designer_flow);
flowTriggers.query();
while (flowTriggers.next()) {
addToUpdateSet('sys_hub_flow_trigger', flowTriggers.sys_id);
}
// Add Subflows (if any)
var subflows = new GlideRecord('sys_hub_action_instance');
subflows.addQuery('flow', catItem.flow_designer_flow);
subflows.addQuery('action', 'com.glide.hub.flow_logic.subflow');
subflows.query();
while (subflows.next()) {
var subflowRef = subflows.getValue('subflow');
if (subflowRef) {
addToUpdateSet('sys_hub_flow', subflowRef);
}
}
}
// 8. Add Legacy Workflow (if attached) - for backward compatibility
if (catItem.workflow) {
gs.info('Found Legacy Workflow');
addToUpdateSet('wf_workflow', catItem.workflow);
// Add workflow activities
var wfActivities = new GlideRecord('wf_activity');
wfActivities.addQuery('workflow', catItem.workflow);
wfActivities.query();
while (wfActivities.next()) {
addToUpdateSet('wf_activity', wfActivities.sys_id);
}
}
// 9. Add Catalog Categories relationship
var categories = new GlideRecord('sc_cat_item_category');
categories.addQuery('sc_cat_item', catItem.sys_id);
categories.query();
gs.info('Found ' + categories.getRowCount() + ' category assignments');
while (categories.next()) {
addToUpdateSet('sc_cat_item_category', categories.sys_id);
}
// 10. Add Record Producers (if it's a record producer)
if (catItem.sys_class_name == 'sc_cat_item_producer') {
var producer = new GlideRecord('sc_cat_item_producer');
if (producer.get(catItem.sys_id)) {
addToUpdateSet('sc_cat_item_producer', producer.sys_id);
}
}
// 11. Add Execution Plans (if any)
var execPlans = new GlideRecord('sc_ic_item_staging');
execPlans.addQuery('cat_item', catItem.sys_id);
execPlans.query();
while (execPlans.next()) {
addToUpdateSet('sc_ic_item_staging', execPlans.sys_id);
}
// 12. Add Catalog Item Tasks / Delivery Plans
var tasks = new GlideRecord('sc_cat_item_delivery_plan');
tasks.addQuery('sc_cat_item', catItem.sys_id);
tasks.query();
while (tasks.next()) {
addToUpdateSet('sc_cat_item_delivery_plan', tasks.sys_id);
}
// 13. Add Variable Choices (for choice lists)
var choices = new GlideRecord('question_choice');
choices.addQuery('question.cat_item', catItem.sys_id);
choices.query();
gs.info('Found ' + choices.getRowCount() + ' variable choices');
while (choices.next()) {
addToUpdateSet('question_choice', choices.sys_id);
}
// 14. Add Requested Items (sc_req_item) - Optional, uncomment if needed
/*
var reqItems = new GlideRecord('sc_req_item');
reqItems.addQuery('cat_item', catItem.sys_id);
reqItems.query();
while (reqItems.next()) {
addToUpdateSet('sc_req_item', reqItems.sys_id);
}
*/
gs.info('===== COMPLETED =====');
gs.info('All catalog item components added to update set successfully!');
})();
