Using a field value as a variable for reference field in expression

#1

I have two types:

Parent {
  rfVals: [double]
}

Child {
  parent: Parent
  fieldOfInterest: string
  parentValues: [double] calc "parent[fieldOfInterest]"
}

If my Child.fieldOfInterest is "rfVals" for instance, how would I get this sort of calc to work?

This returns Error: wrapped IndexOutOfBoundsException: Index: 0

#2

What you are basically trying to do is parent.fieldName. Since the fieldName is dynamic you want an api like fieldValue(obj, name)

Currently this api doesn’t exist but in v7.9 you can have any custom expressions added at the application level even if its not available as a part of the platform.

#3

Thanks, @rohit.sureka!