Skip to content

Commit 9069f34

Browse files
Deactivate and reactivate catalog items (#975)
* Create readme.md * Update readme.md * Create schedule-deactivation.js * Add files via upload
1 parent b5ce85e commit 9069f34

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
91.9 KB
Loading
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Scheduled Deactivation/Reactivation of Forms
2+
3+
A scheduled job script to deactivate and reactivate forms automatically during a maintenance window.
4+
5+
## Description
6+
7+
This script can be added to a scheduled job to deactivate and reactivate catalog items and/or record producers. An example of a use case is where maintenance is being performed which will involve a system outage so certain forms that might rely on an integration with that system need to be disabled during the maintenance window.
8+
9+
## Getting Started
10+
11+
### Dependencies
12+
13+
* None
14+
15+
### Execution
16+
17+
1. Create a scheduled job that automatically runs a script of your choosing.
18+
2. Configure the scheduled job to run at the relevant time (see image for example).
19+
3. Copy the script from deactivate-reactivate-cat-item.js into the 'Run this script' field.
20+
4. Modify the variables as required:
21+
* Add or remove variables to capture all of the catalog items that need to be deactivated/reactivated.
22+
* Ensure the sys_id of the catalog item is set as the variable value.
23+
5. Update the array list on line 8 to include the variables you want to use.
24+
6. Set the value of the active flag on line 11 to 'false' to deactivate the catalog item or 'true' to activate the catalog item.
25+
7. Save the scheduled job and it will run once the trigger condition is met.
26+
27+
### Additional Information
28+
If you are setting a deactivate scheduled job for a maintenance window, make sure you create a second scheduled job to reactivate the catalog items once the maintenance window is closed.
29+
30+
## Authors
31+
32+
Brad Warman
33+
34+
https://www.servicenow.com/community/user/viewprofilepage/user-id/80167
35+
36+
## Version History
37+
38+
* 0.1
39+
* Initial Release
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Configure a variable for each catalog item that needs to be deactivated/reactivated. Variable value needs to be the catalog item sys_id
2+
var newITAccountForm = 'acbf71d7dbd3341087d5bc56f39619d8';
3+
var modifyITAccountForm = 'bdcaa8f6db58ff00ee115d87f49619b3';
4+
var dlManagementForm = 'a7d613e0dbce7740ee115d87f496193c';
5+
var sharedMailboxManagementForm = '04eabdd1dbc67340de2e32e43a96196c';
6+
7+
// Add the vatalog item variables to the array as required
8+
var array = [modifyITAccountForm, dlManagementForm, sharedMailboxManagementForm];
9+
10+
for (item in array) {
11+
var grItem = new GlideRecord('sc_cat_item');
12+
grItem.get(array[item]);
13+
grItem.setValue('active', false); // False to deactivate, True to activate.
14+
grItem.update();
15+
}

0 commit comments

Comments
 (0)