The GlideApplicationProperty API provides methods to get and set application property values for a specific domain.

Application properties enable service providers to customize application functionality based on the domain. Instead of only having a single system property (System Property [sys_properties] table) that defines the functionality for all domains and users, application properties can be implemented to define functionality for specific domains.

To access this API you must activate the Domain Support - Domain Extensions Installer (com.glide.domain.msp_extensions.installer) plugin.

For additional information on domain-specific application properties, see Domain-separated application properties.

GlideApplicationProperty - getValue(String name, String domainSysId)

Returns the value for the specified application property and domain sys_id.

The list of available application properties is located in the Application Properties [sys_application_property] and Application Property Values [sys_application_property_value] tables.

Note: If the specified domain is a child domain, and there is not an application property for the child domain, the method returns the parent domain application property, if available.
Table 1. Parameters
Name Type Description
name String Name of the application property to return.
Note: If the application is not global, you must prefix the name of the sys_application_property with the application's scope.
domainSysId String Optional. Sys_id of the domain associated with the application property.

Default: Session domain

Table 2. Returns
Type Description
String Value of the specified application property for the specified domain. If domainSysId is not passed in the call, then returns the session domain.

If the specified application property doesn't exist, returns the same-name system property value.

If the user does not have access rights to the specified domain, throws an exception and no value is returned.

Example

This example shows how to create a new application property and override its value for ACME and Cisco domains.

var MY_APP_PROP_NAME = 'my-app-prop';
var ACME_DOMAIN_ID = 'c90d4b084a362312013398f051272c0d';
var CISCO_DOMAIN_ID = 'c90f91924a362312001bdefae0f35d68';

// create a new app_config entry:
var now_GR = new GlideRecord('sys_application_property');
now_GR.name = MY_APP_PROP_NAME; 
now_GR.default_value = 'my-app-prop-default_value'; 
now_GR.insert();

// Override the value for ACME domain, catch exception if user can't access the specified domain
try {
  GlideApplicationProperty.setValue(MY_APP_PROP_NAME, 'prop-value-ACME', ACME_DOMAIN_ID);
  gs.info('Value for ACME domain: ' + GlideApplicationProperty.getValue(MY_APP_PROP_NAME, ACME_DOMAIN_ID));
} catch (ex) {
  gs.info('Exception: ' + ex);
}

// Override the value for Cisco domain -- assuming that the current session domain is Cisco. Notice that we don't pass domain-id explicitly
session.setDomainID(CISCO_DOMAIN_ID); // NOTE: this API is not available from non-global scope (use domain-picker to switch to Cisco)
gs.info('Domain: ' + session.getCurrentDomainID());
GlideApplicationProperty.setValue(MY_APP_PROP_NAME, 'prop-value-Cisco');
gs.info('Value for current session (Cisco) domain: ' + GlideApplicationProperty.getValue(MY_APP_PROP_NAME));
Output:
*** Script: Value for ACME domain: prop-value-ACME
*** Script: Domain: c90f91924a362312001bdefae0f35d68
*** Script: Value for current session (Cisco) domain: prop-value-Cisco

GlideApplicationProperty - setValue(String name, String value, String domainSysId)

Stores the specified value in the specified application property for the specified domain, or the current session domain if not specified.

The following are guidelines for using this method:
  • The application property is not created if its name contains one of the following strings:
    • glide.properties.blacklist
    • glide.properties.no_db_override
    • glide.properties.safe_overrides
    • glide.properties.maint_write_roles
  • The application property is not created if there is an existing system property with the same name, and the system property is marked as private.
  • The application property is not created if there is an existing system property and the application property does not reference it.
  • The name of the application property in the sys_application_property table is prefixed with the application's scope if it is not global.
  • This method cannot be called from a different scope.
Table 3. Parameters
Name Type Description
name String Name of the application property to save.
Note: If the application is not global, you must prefix the name of the sys_application_property with the application's scope.
value String Value to store in the specified application property.
domainSysId String Optional. Sys_id of the domain associated with the application property.

Default: Current session domain

Table 4. Returns
Type Description
Boolean Flag that indicates whether the save operation was successful.
Valid values:
  • true: Value was successfully saved.
  • false: An error occurred and the application property was not created/updated.

If the user does not have access rights to the specified domain, throws an exception and no value is returned.

Example

This example shows how to create a new application property and override its value for ACME and Cisco domains.

var MY_APP_PROP_NAME = 'my-app-prop';
var ACME_DOMAIN_ID = 'c90d4b084a362312013398f051272c0d';
var CISCO_DOMAIN_ID = 'c90f91924a362312001bdefae0f35d68';

// create a new app_config entry:
var now_GR = new GlideRecord('sys_application_property');
now_GR.name = MY_APP_PROP_NAME; 
now_GR.default_value = 'my-app-prop-default_value'; 
now_GR.insert();

// Override the value for ACME domain, catch exception if user can't access the specified domain
try {
  GlideApplicationProperty.setValue(MY_APP_PROP_NAME, 'prop-value-ACME', ACME_DOMAIN_ID);
  gs.info('Value for ACME domain: ' + GlideApplicationProperty.getValue(MY_APP_PROP_NAME, ACME_DOMAIN_ID));
} catch (ex) {
  gs.info('Exception: ' + ex);
}

// Override the value for Cisco domain -- assuming that the current session domain is Cisco. Notice that we don't pass domain-id explicitly
session.setDomainID(CISCO_DOMAIN_ID); // NOTE: this API is not available from non-global scope (use domain-picker to switch to Cisco)
gs.info('Domain: ' + session.getCurrentDomainID());
GlideApplicationProperty.setValue(MY_APP_PROP_NAME, 'prop-value-Cisco');
gs.info('Value for current session (Cisco) domain: ' + GlideApplicationProperty.getValue(MY_APP_PROP_NAME));
Output:
*** Script: Value for ACME domain: prop-value-ACME
*** Script: Domain: c90f91924a362312001bdefae0f35d68
*** Script: Value for current session (Cisco) domain: prop-value-Cisco