Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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.');
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
create below system property sys_properties table and set sys id for store applications - eg 31774a2953839110a6f8ddeeff7b12cb
*/

auto_upgrade_store_apps
Loading