cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Data table creation through service scripting

muzzammil
12-Amethyst

Data table creation through service scripting

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

ACCEPTED SOLUTION

Accepted Solutions
mnarang
17-Peridot
(To:muzzammil)

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 

View solution in original post

5 REPLIES 5
mnarang
17-Peridot
(To:muzzammil)

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 

muzzammil
12-Amethyst
(To:mnarang)

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

mnarang
17-Peridot
(To:muzzammil)

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 

muzzammil
12-Amethyst
(To:mnarang)

@mnarang Thank you...it was helpful

mnarang
17-Peridot
(To:muzzammil)

Can you please mark it as accepted solution so that it can help other people as well !!

 

 

Thanks ,

Mukul Narang 

Announcements


Top Tags