how to rename the field of infotable in thingworx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
how to rename the field of infotable in thingworx
how to rename the field of infotable(result of queryDatatableEntries)?
- Labels:
-
Troubleshooting
- Tags:
- infotables
- javascript
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
FYI, I need to display data in time series chart.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
![](/skins/images/695EE5AD3E567050FEDD72575855ED93/ptc_skin/images/icon_anonymous_message.png)