Add or Update Data Table
AddOrUpdateDataTableEntry Description
Generates the code required to add a stream entry to the selected stream thing. Note that parts of the auto generated code has to be updated with values for the entry. Specifically:
Values: The values will by default be set to 'undefined'. Either hard code a value, assign the value from the service parameter, or from another variable.
Location: The location object by default is set to 0 for the longitude, latitude, and elevation. If these values are known, they can be updated.
Tags: By default, the tags object does not have any values.
Timestamp: By default, the current time is used. This can be any value providing its a datetime.
The values, location, tags, timestamp, and source are used in the AddStreamEntry service call.
Inputs
Parameter Name
Description
Base Type
tags
Data Tags for the entries (optional).
TAGS
location
Location of the entry (optional).
LOCATION
source
Source of the entry (optional).
STRING
sourceType
Source type (optional).
STRING
values
Values to be added or updated in the data table.
INFOTABLE
Output
Parameter Name
Description
Base Type
Result
Returns a STRING value of the streamID of the new or updated entry in the data table
STRING
Example

// tags:TAGS
let tags = new Array();

// values:INFOTABLE(Datashape: DTAuditShape)
let values = Things["AuditDataTable"].CreateValues();
values.auditCategory = undefined; // STRING
values.messageArgs = undefined; // INFOTABLE
values.id = undefined; // GUID [Primary Key]
values.message = undefined; // STRING
values.user = undefined; // STRING

// location:LOCATION
let location = {
latitude: 0,
longitude: 0,
elevation: 0,
units: "WGS84"
};

let params = {
tags: tags,
source: me.name,
values: values,
location: location
};

// AddOrUpdateDataTableEntry(tags:TAGS, source:STRING("me.name"), values:INFOTABLE(AuditDataTable), location:LOCATION):STRING
let id = Things["AuditDataTable"].AddOrUpdateDataTableEntry(params);

AddOrUpdateDataTableEntries Description
The AddOrUpdateDataTableEntries is used to add and update entries in a DataTable.
Input
Parameter Name
Description
Base Type
tags
Data Tags for the entries (optional).
TAGS
location
Location of the entry (optional).
LOCATION
source
Source of the entry (optional).
STRING
sourceType
Source type (optional).
STRING
values
Values to be added or updated in the data table.
INFOTABLE
Output
There is no output for AddOrUpdateDataTableEntries.
Example
// Define the parameters for creating the InfoTable
var params = {
infoTableName : "InfoTable",
dataShapeName : "EmployeesDataShape"
};
// Create the InfoTable
var valuesInfotable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
// Define a updated entry to be added
var UpdatedValuesRow = {
EmployeeID: "209833",
Name: "Vishal",
Role: "Software Engineer Specialist",
Salary: "50000"
};
// Add the new row to the InfoTable
valuesInfotable.AddRow(UpdatedValuesRow);
// Define a new entry to be added
var addValuesRow = {
EmployeeID: "209838",
Name: "Sagar",
Role: "QA",
Salary: "40000"
};
// Add the new row to the InfoTable
valuesInfotable.AddRow(addValuesRow);
Things["EmployeesDataTable"].AddOrUpdateDataTableEntries({
sourceType: undefined /* STRING */,
values: valuesInfotable /* INFOTABLE */,
location: undefined /* LOCATION */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
});
Was this helpful?