Power-Fx
Power-Fx copied to clipboard
Untyped object: loop through fields of a record
IUntypedObject can enumerate the property names of an untyped object; but this is not exposed at power fx level.
Request is to treat the Untyped Object like a dictionary and enumerate the keys and get the value for each key.
If X is an UO, either:
Option 1:
ForAll(Keys(x) as K, $"Key={K.Value}, Value={Text(GetField(x, K.value))}")
This requires:
- enumerating the keys (Keys)
- as well as dynamic lookup (GetField).
- efficient dynamic type checks.
GetDisplayName("crf38_name", "crf38_myTable") // "Name"
Option2: GetKeyValues(x) - IEnumerable<string, UntypedObject>
ForAll(GetKeyValues(x), $"Key={ThisRecord.FieldName}, Value={Text(ThisRecord.Value)}")
Can we support Index() on GetKeyValues() ?
Can we support Index() on GetKeyValues() ?
The type of either Keys or GetKeyValues will be a table (either *[Value:s] or *[FieldName:s,Value:O]), and as such the Index function will just work on it.