About the script include "NotificationPreferenceUI"

bonsai
Mega Sage

Contents of OOTB script include "NotificationPreferenceUI"

 

var NotificationPreferenceUI = Class.create();
NotificationPreferenceUI.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	type: 'NotificationPreferenceUI',

	isCMS: function() {
		var transaction = GlideTransaction.get();
		return transaction && transaction.isVirtual();
	},

	isLegacySubscription: function() {
		return GlideProperties.getBoolean('glide.notification.use_legacy_subscription_model', false);
	},

	isMobile: function() {
		return gs.isMobile();
	},

	isConcourse: function() {
		return gs.getPreference('use.concourse') == 'true';
	},

	isPluginActive: function() {
		return GlidePluginManager.isActive('com.glide.notification.preference.ui');
	},

	isUIPropertyEnabled: function() {
		return GlideProperties.getBoolean('glide.notification.preference.ui.enabled', false);
	},

	enabled: function (options) {
		options = options || {};

		var check = function(opt, fn) {
			if (typeof opt != 'undefined')
				return opt;
			return fn.call();
		};

		if (check(options.cms, this.isCMS))
			return false;

		if (check(options.legacySubscription, this.isLegacySubscription))
			return false;

		if (check(options.mobile, this.isMobile))
			return false;

		return check(options.concourse, this.isConcourse) &&
			check(options.pluginActive, this.isPluginActive) &&
			check(options.uiPropertyEnabled, this.isUIPropertyEnabled);
	}
});

 

What does the following process in the above script do?

	isCMS: function() {
		var transaction = GlideTransaction.get();
		return transaction && transaction.isVirtual();
	},

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@bonsai 

Unfortunately, there is no API reference available for GlideTransaction. Its a java class which you cannot access it directly.

This is what my understanding is

it checks the current transaction and checks if it exists and is virtual. A virtual transaction in ServiceNow typically refers to a transaction that is not initiated by a direct user interaction, such as those triggered by workflows, scheduled jobs, or other automated processes.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@bonsai 

Unfortunately, there is no API reference available for GlideTransaction. Its a java class which you cannot access it directly.

This is what my understanding is

it checks the current transaction and checks if it exists and is virtual. A virtual transaction in ServiceNow typically refers to a transaction that is not initiated by a direct user interaction, such as those triggered by workflows, scheduled jobs, or other automated processes.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader