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

How to Create Data shape Through Service in Thingworx

SOLVED
Alexandrite

How to Create Data shape Through Service in Thingworx

Hi Everyone,

 

I like to Create Datashape through TWX service with multiple number of Fields.

I found the Snippet in Thingworx its like. 

 

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

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

 

but i don't know How to give fields in the above snippet.

 

if anybody Know any solution  regarding this,Kindly share it  ASAP.

 

Thanks & Regards 

Sugumar R

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How to Create Data shape Through Service in Thingworx

You should pass an Infotable with the desired fields formats, or a JSON Infotable, here an example of the second opcion:

 

var fields = { dataShape: {"fieldDefinitions":
                              {"fieldName1":
                                   {"name":"fieldName1", 
                                     "aspects":{},
                                     "description":"",
                                     "baseType":"NUMBER",
                                     "ordinal":1},
                               "fieldName2":
                                   {"name":"fieldName2",
                                    "aspects":{},
                                    "description":"",
                                    "baseType":"INTEGER",
                                    "ordinal":2}
                                   }
                          },
               rows: [] 
             };


Resources["EntityServices"].CreateDataShape( {
	name: "newDataShapeName",
	description: undefined ,
	fields: fields,
	tags: undefined
});

View solution in original post

4 REPLIES 4

Re: How to Create Data shape Through Service in Thingworx

Hello @Sugumar 

 

PFB snippet to add Field Definition to Datashape

 

var params = {
 name: FIELDNAME /* STRING */,
 description: undefined /* STRING */,
 type: 'NUMBER' /* BASETYPENAME */,
 ordinal: undefined /* INTEGER */,
 primaryKey: undefined /* BOOLEAN */,
 dataShape: undefined /* DATASHAPENAME */
 };

 // no return
 DataShapes[DatashapeName].AddFieldDefinition(params);

Regards,
VR

Re: How to Create Data shape Through Service in Thingworx

Hai Velkumar,

 

Thank You for your reply.

I already used the snippet what you  shared. It is actually used to add fields one by one to the already created Datashape.

 

But i required to create multiple number of fields when i am creating the data shape itself. 

 

Thanks & Regards

Sugumar R

Highlighted

Re: How to Create Data shape Through Service in Thingworx

You should pass an Infotable with the desired fields formats, or a JSON Infotable, here an example of the second opcion:

 

var fields = { dataShape: {"fieldDefinitions":
                              {"fieldName1":
                                   {"name":"fieldName1", 
                                     "aspects":{},
                                     "description":"",
                                     "baseType":"NUMBER",
                                     "ordinal":1},
                               "fieldName2":
                                   {"name":"fieldName2",
                                    "aspects":{},
                                    "description":"",
                                    "baseType":"INTEGER",
                                    "ordinal":2}
                                   }
                          },
               rows: [] 
             };


Resources["EntityServices"].CreateDataShape( {
	name: "newDataShapeName",
	description: undefined ,
	fields: fields,
	tags: undefined
});

View solution in original post

Re: How to Create Data shape Through Service in Thingworx

Thank you so much CarlesColl ...

 

Its Working Perfectly CarlesColl .

 

Thanks& Regards

Sugumar R

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________