Name

sn_cmp.CMPSysChoiceLabelResolver

Description

Script used to resolve conflicts with getChoiceValue (GlideRecord API call) when a language pack is installed on an instance.

Script

var CMPSysChoiceLabelResolver = Class.create();
CMPSysChoiceLabelResolver.prototype = {
  initialize: function() {
  },
  /**
  * Retrieves choice 'label' for given choice 'value', table, choice 'field'
  **/
  fetchChoiceLabel: function(choiceValue,tableName,choiceField){

  	var choiceGR = new GlideRecord("sys_choice");
  	choiceGR.addQuery("name",tableName);
  	choiceGR.addQuery("element",choiceField);
  	choiceGR.addQuery("value",choiceValue);
  	choiceGR.addQuery("language","en");
  	choiceGR.query();
  	if(choiceGR.next())
  		return choiceGR.getValue("label");
  	else
  		return "";
  },
  type: 'CMPSysChoiceLabelResolver'
};

Sys ID

45c18ca667250300a7526c706785ef15

Offical Documentation

Official Docs: