Absent Member.. Absent Member..
Absent Member..

Get type of field ($L.source) with JavaScript in Link file?

Hello HPSM Community,

we tried to identify $L.source fields types to fill some of them dynamically and tried following line:


for example in case of ci

we want to see if its a string, boolean, array or structure... unfortunately this line always gives back "object". Any other way/idea to get correct type?

Thx and br


2 Replies
Honored Contributor.. Honored Contributor..
Honored Contributor..

try this

Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

I'm unclear on what you're trying to do.  What's the $L.source variable?  What's your javascript look like?

If you're trying to determine the data type of a particular element, you can do that with the 'system.functions.type', or there is the javascript native function typeof...

Let's pretend you're trying to generate a javascript that will take a value from a record as a parameter and return for you the data type of that value.  (You wouldn't need javascript to do this, but let's pretend you wanted to use javascript for some reason).

function getType(field){
	var sourceType = system.functions.type(field);
	if (sourceType == 1)
		return "number";
	if (sourceType == 2)
		return "character";
	if (sourceType == 3)
		return "date/time";
	if (sourceType == 4)
		return "logical";
	if (sourceType == 5)
		return "label";
	if (sourceType == 6)
		return "file/record";
	if (sourceType == 7)
		return "offset";
	if (sourceType == 8)
		return "array";
	if (sourceType == 9)
		return "structure";
	if (sourceType == 10)
		return "operator";
	if (sourceType == 11)
		return "expression";

basically, this script takes the OOB function 'type' which returns the Service Manager data types as a numeric value, and converts it into plaintext.


The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.