Can I type cast in a metric expression?


#1

I have a type (SmartBulb) that extends another type (LightBulb). bulbMeasurement is a collection field defined on SmartBulb.

I am now trying to traverse my data model and am ending at a LightBulb but I really need to get to bulbMeasurement.

All my LightBulbs are SmartBulbs and vice versa.

Is there some way to type cast LightBulb as SmartBulb in my expression?


#2

Currently this is not supported, but the feature has been requested and is being currently developed.

A useful work around is to use a stored calc field to traverse the same path as your metric, and do the type casting in that stored calc, eg:
aircraftShortcut : Aircraft stored calc "slots.parent.assets.(Aircraft)[0]"
…the (Aircraft) is the typecasting piece…

Then you can write your metric to use this stored calc field.


Is it possible to type cast in an expression?
Using a cast in a metric for checking the typeIdent of a party role
#3

This probably can be just

aircraftShortcut : Aircraft calc "slots.parent.assets.(Aircraft)[0]

which has the same logic but doesn’t incur the storage or processing overhead of a STORED calc