Skip to main content
10-Marble
Mar 7, 2018 4:43 PM UTC
Solved

How to get the fields definition of an InfoTable

Is it possible to get the field definition of an InfoTable prior to knowing its DataShape?

 

I am currently doing it by converting my InfoTable to json and then by taking the dataShape definition:

 

var fields = Resources["InfoTableFunctions"].ToJSON(params);
var result = fields.dataShape.fieldDefinitions;

This works fine but I'm wondering if there is a nicer way to do this, by using services like getDataShape and GetFieldDefinitions.

1-Visitor
Mar 8, 2018 2:59 PM UTC

The correct way of recovering the Fields of an Infotable with and unknown DataShape it's this one:

 

var iLF ;
if ((myInfotable.dataShape==null)||(myInfotable.dataShape==undefined)) {
 iLF = myInfotable.ToJSON().dataShape.fieldDefinitions;
 } else {
 iLF = myInfotable.dataShape.fields;
 }
for (var key in iLF) {
 logger.info("Field Name "+key+" baseType: "+iLF[key].baseType);
}

4 replies

22-Sapphire I
Mar 7, 2018 9:45 PM UTC

There was a similar thread to this before.

I think you can just do something like

for each (var field in myinfotable.fields)

Translate
1-Visitor
Mar 8, 2018 2:59 PM UTC

The correct way of recovering the Fields of an Infotable with and unknown DataShape it's this one:

 

var iLF ;
if ((myInfotable.dataShape==null)||(myInfotable.dataShape==undefined)) {
 iLF = myInfotable.ToJSON().dataShape.fieldDefinitions;
 } else {
 iLF = myInfotable.dataShape.fields;
 }
for (var key in iLF) {
 logger.info("Field Name "+key+" baseType: "+iLF[key].baseType);
}
Translate
Ascherer17
16-Pearl
Jul 2, 2018 6:28 PM UTC

This is very helpful!  Thank you.

Translate
Emeritus
Apr 5, 2018 12:33 PM UTC

Hi @pruby

Did Carles reply solve your issue? If so, please mark this as an Accepted Solution for the benefit of the rest of our Community. If not, let us know the current situation.

 

Thanks!

Leigh

Translate