Code problems with Datashape/table
Hi All,
I am trying to create a service that creates a datatable and also its datashape ( from an transposed infotable created from inputed user data).
The question is...why this code doesnt work?
// FOR DATATABLE CREATION
var params = {
name: "Thing_Name"/* STRING */,
description: undefined /* STRING */,
thingTemplateName: "DataTable" /* THINGTEMPLATENAME */,
tags: undefined /* TAGS */
};
// no return
Resources["EntityServices"].CreateThing(params);
//INFOTABLE WITH SOME DATA FROM USER
var paramsu = {
maxItems: undefined /* NUMBER */
};
var tablete = me.GetDataTableEntries(paramsu);
//TRANSPOSED INFOTABLE FOR DATASHAPE
var p = {
infoTableName: undefined /* STRING */
};
var trans= Resources["InfoTableFunctions"].CreateInfoTable(p);
for( var i = 0;i< tablete.getRowCount();i++){
trans.AddField({name: tablete[i].nome, baseType: "STRING"});
}
//DATASHAPE creation
var par = {
name: "myds" /* STRING */,
description: undefined /* STRING */,
fields: trans/* INFOTABLE */,
tags: undefined /* TAGS */
};
Resources["EntityServices"].CreateDataShape(par);
Things["Thing_Name"].SetDataShape({ name: "myds" });
Things["Thing_Name"].EnableThing();
Things["Thing_Name"].RestartThing();

