Skip to main content
1-Visitor
August 8, 2018
Question

Update datatable Failure

  • August 8, 2018
  • 1 reply
  • 962 views

This may be a basic question. But why does this fail ?, What is the right way to update ?

var values = Things["TestDataTable"].CreateValues();
values.Id = Id; //INTEGER [Primary Key]
values.Name = "Name"+Id; //STRING

var params = {
	maxItems: undefined /* NUMBER */,
	values: values /* INFOTABLE*/,
	query: undefined /* QUERY */,
	source: undefined /* STRING */,
	tags: undefined /* TAGS */
};
// result: INFOTABLE
var table = Things["TestDataTable"].QueryDataTableEntries(params);

if(table.length>1)
{
var row = table[0];
var values = Things["TestDataTable"].CreateValues();
values.Attendance = 11; //NUMBER
values.RollNum = row.RollNum; //STRING [Primary Key]
values.Percent = 11; //INTEGER
values.Id = row.Id; //INTEGER [Primary Key]
values.Name = row.Name; //STRING

var params = {
	sourceType: undefined /* STRING */,
	values: values /* INFOTABLE*/,
	location: undefined /* LOCATION */,
	source: undefined /* STRING */,
	tags: undefined /* TAGS */
};
// no return
Things["TestDataTable"].UpdateDataTableEntries(params);
}

 

1 reply

5-Regular Member
August 13, 2018

Hi @skumar-81 could you share what the exact error is?