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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Fetch Datashape from a infotable as a string

cmartis
4-Participant

Fetch Datashape from a infotable as a string

Hi Team,

 

I have a infotable that contains a list of info tables as it fields.

I am trying to fetch datashape of the infotable present in each field.

But it always returns result as com.thingworx.metadata.DataShapeDefinition@e69545d5

Using the above result as params  I am not able create a infotable .

 

Can someone help with syntax with which the above result may be used to fetch exact name of datashape used in infotable as string 

4 REPLIES 4
supandey
19-Tanzanite
(To:cmartis)

Hi @cmartis would it be possible for you to share how you are attempting to extract the name of the datashape? 

Use the following code to know the fields of the corresponding datashapes:

 

 

 var fields ;
    if ((infotable.dataShape==null)||(infotable.dataShape==undefined)) {
        fields = infotable.ToJSON().dataShape.fieldDefinitions;
    } else {
        fields = infotable.dataShape.fields;
    }

 

jamesm1
5-Regular Member
(To:cmartis)

Hey @cmartis,

 

It is not possible to derive the DataShape name from an InfoTable. The underlying structure of an InfoTable, which can be viewed in JSON, is this:

 

{  
   "dataShape":{  
      "fieldDefinitions":{  
         "val1":{  
            "name":"val1",
            "description":"",
            "baseType":"NUMBER",
            "ordinal":1,
            "aspects":{  

            }
         },
         "val2":{  
            "name":"val2",
            "description":"",
            "baseType":"NUMBER",
            "ordinal":2,
            "aspects":{  

            }
         }
      }
   },
   "rows":[  
      {  
         "val1":10,
         "val2":12
      }
   ]
}

Note that the object contains the fieldDefinitions, with all of their types, but not the Entity name of the DataShape the InfoTable was created from. 

 

Why do you need to find the Data Shape name? If you just need to create an InfoTable of the same DataShape, you can create it in JSON -- using the dataShape JSON from the InfoTable -- with the above format and use the FromJSON() snippet. If you need to iterate through the fields, you can use @CarlesColl's example in this thread.

cmartis
4-Participant
(To:cmartis)

Hi all,

 

I could fetch the datashape of the info table that resides with Info table's aspects property

Top Tags