Name

sn_cd.cd_PropertiesAJAX

Description

Client APIs for getting content property values

Script

var cd_PropertiesAJAX = Class.create();
cd_PropertiesAJAX.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
  
  /** 
   * Get a supported property value. Allowed properties are defined in cd_CommonConstants
  **/
  getProperty: function () {
  	var params = JSON.parse(this.getParameter('sysparm_value'));
  	var propertyName = params.propertyName;
  	var defaultValue = params.defaultValue;
  	var supportedProperties = cd_CommonConstants.SUPPORTED_AJAX_PROPERTIES;
  	var value = defaultValue;

  	for (var propertyIdx = 0; propertyIdx < supportedProperties.length; propertyIdx++)
  		if (propertyName === supportedProperties[propertyIdx])
  			value = this._getPropertyHelper(propertyName, defaultValue);

  	return JSON.stringify({
  		propertyName : propertyName,
  		value : value
  	});
  },

  _getPropertyHelper: function(propertyName, defaultValue) {
  	var value;
  	if (propertyName === cd_CommonConstants.PORTAL_URL_SUFFIX_PROPERTY) {
  		// Check valid portal
  		value = gs.getProperty(propertyName, defaultValue);
  		var grPortal = new GlideRecord('sp_portal');
  		if (!grPortal.get('url_suffix', value))
  			value = defaultValue;
  	} else
  		value = gs.getProperty(propertyName, defaultValue);

  	return value;
  },

  type: 'cd_PropertiesAJAX'
});

Sys ID

28021f213d1f0110fa9b5061e86e1a3f

Offical Documentation

Official Docs: