From a3e9c139bda9d89a78cd2afb6415bc232bfcdb19 Mon Sep 17 00:00:00 2001 From: bharakm Date: Sun, 19 Oct 2025 16:00:10 -0500 Subject: [PATCH 1/3] Create Readme.md --- .../Auto upgrade store applications/Readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Server-Side Components/Scheduled Jobs/Auto upgrade store applications/Readme.md diff --git a/Server-Side Components/Scheduled Jobs/Auto upgrade store applications/Readme.md b/Server-Side Components/Scheduled Jobs/Auto upgrade store applications/Readme.md new file mode 100644 index 0000000000..65480bed5f --- /dev/null +++ b/Server-Side Components/Scheduled Jobs/Auto upgrade store applications/Readme.md @@ -0,0 +1,8 @@ +This script will automatically upgrade the Store applications of your choice, based on a system property. + +A few key points about this approach: +• The script upgrades only the applications listed in the system property (auto_upgrade_store_apps) and applications that are included as child. +• It can be scheduled to run automatically or triggered manually. +• You can add an email notification, a banner, or another form of alert to notify admins about which applications were updated. + +This is a simple way to save time and keep Store applications up to date without manual intervention. From 4f0257aa960a21fa98ad856720e775798089182b Mon Sep 17 00:00:00 2001 From: bharakm Date: Sun, 19 Oct 2025 16:04:35 -0500 Subject: [PATCH 2/3] Create script.js --- .../Auto upgrade store applications/script.js | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Server-Side Components/Scheduled Jobs/Auto upgrade store applications/script.js diff --git a/Server-Side Components/Scheduled Jobs/Auto upgrade store applications/script.js b/Server-Side Components/Scheduled Jobs/Auto upgrade store applications/script.js new file mode 100644 index 0000000000..926c080f50 --- /dev/null +++ b/Server-Side Components/Scheduled Jobs/Auto upgrade store applications/script.js @@ -0,0 +1,45 @@ +upgradeSelectedStoreApps(); + +function upgradeSelectedStoreApps() { + var propertyName = "auto_upgrade_store_apps"; + var storeAppsList = gs.getProperty(propertyName, ""); + if (!storeAppsList) { + gs.info("No store applications listed for auto-upgrade."); + return; + } + var appsToUpgrade = storeAppsList.split(",").map(function(app) { + return app.trim(); + }); + var upgradedApps = []; + var storeAppGr = new GlideRecord('sys_store_app'); + storeAppGr.addQuery('active', true); // Only active store applications + storeAppGr.addQuery('sys_id', 'IN', appsToUpgrade); // Filter by system property list + storeAppGr.query(); + while (storeAppGr.next()) { + var appId = storeAppGr.getValue('sys_id'); + var appName = storeAppGr.getValue('name'); + var currentVersion = storeAppGr.getValue('version'); + var availableVersion = storeAppGr.getValue('latest_version'); + if (availableVersion && currentVersion !== availableVersion) { + try { + gs.info('Upgrading store application: ' + appName + ' from version ' + currentVersion + ' to ' + availableVersion); + var worker = new sn_appclient.AppUpgrader(); + storeUpgradeResult = worker.upgrade(appId.toString(), availableVersion.toString(), false); + if (storeUpgradeResult) { + gs.info('Store application "' + appName + '" upgraded successfully.'); + upgradedApps.push({ + name: appName, + fromVersion: currentVersion, + toVersion: availableVersion + }); + } else { + gs.error('Failed to upgrade store application: ' + appName); + } + } catch (e) { + gs.error('Error upgrading store application "' + appName + '": ' + e.message); + } + } else { + gs.info('Store application "' + appName + '" is already up-to-date.'); + } + } +} From 002041231c66d73cbca94a05c1437238389f3352 Mon Sep 17 00:00:00 2001 From: bharakm Date: Sun, 19 Oct 2025 16:05:48 -0500 Subject: [PATCH 3/3] Create sysproperty.js --- .../Auto upgrade store applications/sysproperty.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Server-Side Components/Scheduled Jobs/Auto upgrade store applications/sysproperty.js diff --git a/Server-Side Components/Scheduled Jobs/Auto upgrade store applications/sysproperty.js b/Server-Side Components/Scheduled Jobs/Auto upgrade store applications/sysproperty.js new file mode 100644 index 0000000000..b1c22305f0 --- /dev/null +++ b/Server-Side Components/Scheduled Jobs/Auto upgrade store applications/sysproperty.js @@ -0,0 +1,5 @@ +/* +create below system property sys_properties table and set sys id for store applications - eg 31774a2953839110a6f8ddeeff7b12cb +*/ + +auto_upgrade_store_apps