Name

global.CTIEvaluator

Description

Script include for use in refactoring of Computer Telephony integrations in accordance with KB0620953 (revised) Example of usage from a global function invoked by cti.do var args = {}; // JavaScript object to pass name/value pairs with args._name = sysparm_caller_name; args._phone = sysparm_caller_phone; args._taskID = sysparm_task_id; args._userID = userID; . . . . (additional statements to accomodate whatever other incoming values from function cti() ) return new CTIEvaluator( ... expression to be evaluated using _name, _phone, etc ..... , args).evaluate();

Script

var CTIEvaluator = Class.create();

CTIEvaluator.prototype = {

  initialize: function(expression, args) {
  	this.expression = expression;
  	this.map = new Packages.java.util.HashMap();
  	for (var prop in args) {
  		this.map.put(prop, args[prop]);
  	}
  },
  
  /**
   *	Evaluates the expression passed to the CTIEvaluator constructor
   *	in the global scope, using temporary global variables in the supplied map.
   *	Returns whatever object is created by the expression which was evaluated.
   **/
  evaluate: function() {

  	var ret = new GlideEvaluator().evaluateStringWithGlobals(this.expression, this.map);
  	
  	// If we got a string back, it will be wrapped as a NativeJavaObject because GlideEvaluator
  	// is an ordinary Java class, not a Rhino ScriptableObject class like GlideRecord for example.
  	// So coerce the value to a normal string before returning it.
  	
  	if (ret instanceof String)
  		ret = ret + '';
  	
  	return ret;
  },
  
  expression: '',
  map: null,

  type: 'CTIEvaluator'
};

Sys ID

22893692c3113200eeed99c8d1d3ae7f

Offical Documentation

Official Docs: