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

how to rename the field of infotable in thingworx

magrawal
2-Explorer

how to rename the field of infotable in thingworx

how to rename the field of infotable(result of queryDatatableEntries)?

7 REPLIES 7
ankigupta
12-Amethyst
(To:magrawal)

Hi Meenakshi Agrawal,

You can create a new service which uses queryDatatableEntries then you can use RenameField snippet to rename the field.

Rename Snippet:

var params = {

  t: undefined /* INFOTABLE */,

  from: undefined /* STRING */,

  to: undefined /* STRING */

};

// result: INFOTABLE

var result = Resources["InfoTableFunctions"].RenameField(params);

I hope it helps.

Thanks Ankit Gupta​,

I need to rename multiple fields, multiple time calling rename snippet will slow down the service..ryt?

What would be the best way to rename multiple fields?

ankigupta
12-Amethyst
(To:magrawal)

There is no snippet available for renaming multiple infotable column in one go.

Can you please share your requirement that why is the renaming of infotable column required?

For e.g. If you are using the output in some Mashup Grid. You can rename the column name in the widget itself instead of changing it in the infotable.

For example I have 2 data tables(in my case it's 500+) with 2 different datashapes, e.g.

datashape of 1st datatbale has following fields:

1) Temperature1

2)Humidity1

datashape of 2nd datatbale has following fields:

1) Temperature2

2)Humidity2

I need to display temperature and humidity in time series chart, So I created a datashape with following fields:

1) Temperature

2)Humidity

I wrote a service which accepts datatable name as parameters and display data of respective data table. The issue I am facing is the fields of both datatables are different, so I need to rename the fields of infotable same as 3rd datashape.

Please let me know if my use case is clear to you?

magrawal
2-Explorer
(To:magrawal)

FYI, I need to display data in time series chart.

ankigupta
12-Amethyst
(To:magrawal)

If I understand your requirement clearly; ideally all the DataTables should be created from a single DataShape to avoid this problem.

I hope you are using a single TimeSeries Chart with Dynamic Data from each Table.

If you have only two fields in the DataTable then you can leave the field name same and TimeSeries chart will show series for both fields automatically and it will change based on Dynamic Data.

If you have multiple fields in the DataTable and you want to show only few of them in the TimeSeries; renaming seems to be the only option per my understanding.

If you are using different charts then you can directly rename the Labels in the Time Series chart itself.

jgorsline
12-Amethyst
(To:magrawal)

Meenakshi,

Any update on this? Was Ankit Gupta's post helpful? If so, could you click on the "correct answer" or "mark as helpful" button and let us know?

Announcements


Top Tags