cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

How to get the fields definition of an InfoTable

pruby
8-Gravel

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 ACCEPTED SOLUTION

Accepted Solutions

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);
}

View solution in original post

4 REPLIES 4
PaiChung
22-Sapphire I
(To:pruby)

There was a similar thread to this before.

I think you can just do something like

for each (var field in myinfotable.fields)

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);
}
Ascherer17
14-Alexandrite
(To:CarlesColl)

This is very helpful!  Thank you.

Leigh
Community Manager
(To:pruby)

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

Top Tags