Develop > Programming > System Language reference > List: RAD functions > RAD function: get.display.value

RAD function: get.display.value

This RAD function returns the display value of a field in a Service Manager file.

Function

get.display.value

Format

get.display.value($file, $fieldname, [index], [bForceFromDB])

Parameters

The following parameters are valid for this function.

Parameter

Description

$file

The $file variable is the file from which you want to retrieve the display value.

$fieldname

The name of a field in the file.

Caution You cannot use a variable for this parameter. For example, $L.display=get.display.value($L.file, "$affected.cis", -1, true) is not supported.

[index]

This parameter is optional.

If the field specified in $fieldname is of the array type, the index is the position number of an element in the array where the element is located.

If the index is not specified or is -1, the entire array is retrieved instead.

[bForceFromDB]

This parameter is optional.

This is a Boolean type variable, which can be true or false. If it is true, this function will bypass the internal display value cache associated with $file, and retrieve the display value directly from the RDBMS.

Factors

If an internal display value cache does not already exist, a null value is returned; however, if bForceFromDB is set to true, the Service Manager server looks for the display value directly from the RDBMS according to the current field value.

For an array type field, if bForceFromDB is set to true, this function combines the value in the display value cache (if any) and the value fetched directly from the RDBMS, and returns the combined value.

For a string type field, if bForceFromDB is set to true, while the Service Manager server cannot find any value from the RDBMS, the value in the display value cache (if any) is returned instead.

There are two ways to create an internal display value cache associated with $file:

  • Use the set.display.value function explicitly.
  • Any time when users enter or change the display value from the client side and the client submits the request to the server side, the internal display value cache is updated. This is automatic and not under the user’s control.

Return values

Can be null, a string type display value, or an array of string type display values.

Examples

function testDisplayValue()
{
	var sql = 'select * from cm3r where number="C10008"';
	var file = new SCFile('cm3r');
	var rc = file.doSelect(sql);

	print( "Field value of assets=" + file.assets );
	print( "Field value of logical.name=" + file.logical_name );

	var darray = new SCDatum();
	darray.push( "aaa" );
	darray.push( "bbb" );
	print( "Value of darray=" + darray );

	system.functions.set_display_value(file, "assets", darray, -1 );

	var value = system.functions.get_display_value(file, "assets" );
	print( "get.display.value for assets from internal display value cache=" + value );

	value = system.functions.get_display_value(file, "assets", -1, true );
	print( "get.display.value for assets from RDBMS=" + value );

	value = system.functions.get_display_value(file, "logical.name" );
	print( "get.display.value for logical.name from internal display value cache=" + value );

	value = system.functions.get_display_value(file, "logical.name", -1, true );
	print( "get.display.value for logical.name from RDBMS=" + value );
}
testDisplayValue();

This example returns the following results:

Field value of assets=[C++ object Datum] - {"CI1000984", "CI1000988"}

Field value of logical.name=CI1000984

Value of darray=[C++ object SCDatum] - {"aaa", "bbb"}

get.display.value for assets from the internal display value cache=[C++ object Datum] - {"aaa", "bbb"}

get.display.value for assets from the RDBMS=[C++ object Datum] - {"adv-Windows-101", "adv-Windows-102", "aaa", "bbb"}

get.display.value for logical.name from the internal display value cache=null

get.display.value for logical.name from the RDBMS=adv-Windows-101