Skip to main content
1-Visitor
March 6, 2019
Solved

Data table creation through service scripting

How can i create data table(s) with its data shape through service scripting?

mnarangAnswer
5-Regular Member
March 7, 2019

The DataShape which you are passing in the above shared code can also be created through script having primary key

 

var result1 = { dataShape: { fieldDefinitions : {abc: {name: "abc", aspects: {isPrimaryKey: true}, description: "", baseType: "STRING", ordinal: 1}} }, rows: [] };


var params = {
name: "DSwithPK" /* STRING */,
description: undefined /* STRING */,
fields: result1 /* INFOTABLE */,
tags: undefined /* TAGS */
};

// no return
Resources["EntityServices"].CreateDataShape(params);

 

 

Hope it helps

Thanks ,

Mukul Narang 

5 replies

5-Regular Member
March 6, 2019

I have done in this way :

 


var params = {
name: "MyTestTable1" /* STRING */,
description: undefined /* STRING */,
thingTemplateName: "DataTable" /* THINGTEMPLATENAME */,
tags: undefined /* TAGS */
};

// no return
Resources["EntityServices"].CreateThing(params);
Things["MyTestTable1"].SetDataShape({
name: "DataShapeWithBoolean" /* DATASHAPENAME */
});
Things["MyTestTable1"].EnableThing();
Things["MyTestTable1"].RestartThing();

 

Hope it helps .

 

Thanks ,

Mukul Narang 

Translate
muzzammil1-VisitorAuthor
1-Visitor
March 7, 2019

how to set the data shape field as the primary key through scripting?

Translate
mnarang5-Regular MemberAnswer
5-Regular Member
March 7, 2019

The DataShape which you are passing in the above shared code can also be created through script having primary key

 

var result1 = { dataShape: { fieldDefinitions : {abc: {name: "abc", aspects: {isPrimaryKey: true}, description: "", baseType: "STRING", ordinal: 1}} }, rows: [] };


var params = {
name: "DSwithPK" /* STRING */,
description: undefined /* STRING */,
fields: result1 /* INFOTABLE */,
tags: undefined /* TAGS */
};

// no return
Resources["EntityServices"].CreateDataShape(params);

 

 

Hope it helps

Thanks ,

Mukul Narang 

Translate