hello,everyone!
I want to change the data in the table automatically through the service.Please tell me what to do.
Solved! Go to Solution.
Hi @Snoopy_hu
Please find below code to update dataTable value through service or subscription
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(DATASHAPENAME)
let data = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "DATASHAPENAME"
});
let newObject = new Object();
newObject.bName = "test1"; // MAP YOUR INPUT FROM SERVICE OR SUBSCRIPTION
newObject.bDate = 25; // MAP YOUR INPUT FROM SERVICE OR SUBSCRIPTION
data.AddRow(newObject);
// id: STRING
let id = Things["DATATABLENAME"].AddOrUpdateDataTableEntry({
sourceType: undefined /* STRING */,
values: data /* INFOTABLE */,
location: undefined /* LOCATION */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
});
/VR
Hi @Snoopy_hu
There are multiple services in DataTable to update data.
You can use any one of services ( based on your requirement ) below to update data in DataTable
/VR
Hi @Velkumar
I tried it and it did work, but how can I get to the point of automatically changing the value through services and subscriptions?
Hi @Snoopy_hu
Please find below code to update dataTable value through service or subscription
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(DATASHAPENAME)
let data = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "DATASHAPENAME"
});
let newObject = new Object();
newObject.bName = "test1"; // MAP YOUR INPUT FROM SERVICE OR SUBSCRIPTION
newObject.bDate = 25; // MAP YOUR INPUT FROM SERVICE OR SUBSCRIPTION
data.AddRow(newObject);
// id: STRING
let id = Things["DATATABLENAME"].AddOrUpdateDataTableEntry({
sourceType: undefined /* STRING */,
values: data /* INFOTABLE */,
location: undefined /* LOCATION */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
});
/VR
You can use the UpdateDataTableEntry service of the DataTable entity for this.
Hi @Rocko
I tried it and it did work, but how can I get to the point of automatically changing the value through services and subscriptions?