Working with Enums(ROEnumType) in JavaScript

For some reason I am not able to reference the Enum values correctly that I exported in my _intf file. Take the sample below for instance.

// Enum: UserTypeEnum
__namespace.UserTypeEnum = function UserTypeEnum() {
  this.value = null;
};
__namespace.UserTypeEnum.prototype = new RemObjects.SDK.ROEnumType();
__namespace.UserTypeEnum.prototype.enumValues = [
    "ChronicleMobileWindows",
    "ChronicleMobileAndroid",
    "ChronicleMobileiOS",
    "ChronicleWeb",
    "ServerMonitor",
    "AuthenticationService",
    "None",
    "Reconnect"
	];
__namespace.UserTypeEnum.prototype.constructor = __namespace.UserTypeEnum;
RemObjects.SDK.RTTI["UserTypeEnum"] = __namespace.UserTypeEnum;

I have tried to reference it directly in my function like this “UserTypeEnum.ChronicleWeb” (no quotes) and it does not fail. However on the server I am getting the wrong value. Can you please tell me what I am doing wrong?

Thanks,
Todd

Support of enums in RO/JS is a bit ugly thing.

F.e. let’s assume that here config is some JS class that should be sent to the server, PortMode is an enumeration, PortMode.COM is an element of that enumeration.

This line won’t work:

config.PortMode = PortMode.COM;

Expected syntax here would be

config.PortMode = new PortMode();
config.PortMode.value = "COM";

Thanks that was what I needed.

1 Like