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
Solved! Go to Solution.
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
});
Hello @Sugumar_5656
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
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
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
});
