Skip to main content
1-Visitor
September 20, 2019
Solved

How to use QueryImplementingThingsWithNamedData?

  • September 20, 2019
  • 1 reply
  • 2148 views

I am trying to use the new QueryImplementingThingsWithNamedData service in Thingworx.

 

According to the help file I need to have the basicPropertyNames as a InfoTable. How does this info table look or where do I get this infotable?

 

This is how my query looks currently:
var result = ThingTemplates["GGC.RC.TT"].QueryImplementingThingsWithNamedData({
maxItems: undefined /* NUMBER */,
basicPropertyNames: "SampleCode" /* INFOTABLE */,
nameMask: undefined /* STRING */,
propertyNames: undefined/* INFOTABLE */,
query: undefined /* QUERY */,
tags: undefined /* TAGS */
});

 

Thanks

Best answer by cmorfin

Hi @AndreaSteyn 

 

Apologies for the delay in answering.

The propertyNames and basicPropertyNames are infoTable using the EntityList system dataShape.

 

For example

var params = {
 infoTableName : "InfoTable",
 dataShapeName : "EntityList"
};

// CreateInfoTableFromDataShape
var propInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

// EntityList entry object
var newEntry = new Object();
newEntry.name = "prop1"; // STRING [Primary Key]
newEntry.description = undefined; // STRING

propInfoTable.AddRow(newEntry);


// CreateInfoTableFromDataShape
var basicpropInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

// EntityList entry object
var newEntry = new Object();
newEntry.name = "name"; // STRING [Primary Key]
newEntry.description = undefined; // STRING

basicpropInfoTable.AddRow(newEntry);



var result = ThingTemplates["CMOTemplate"].QueryImplementingThingsWithNamedData({
maxItems: undefined /* NUMBER */,
nameMask: undefined /* STRING */,
propertyNames: propInfoTable,
basicPropertyNames: basicpropInfoTable,
query: undefined /* QUERY */,
tags: undefined /* TAGS */
});

 

Hope this helps

Christophe

 

1 reply

cmorfin19-TanzaniteAnswer
19-Tanzanite
October 2, 2019

Hi @AndreaSteyn 

 

Apologies for the delay in answering.

The propertyNames and basicPropertyNames are infoTable using the EntityList system dataShape.

 

For example

var params = {
 infoTableName : "InfoTable",
 dataShapeName : "EntityList"
};

// CreateInfoTableFromDataShape
var propInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

// EntityList entry object
var newEntry = new Object();
newEntry.name = "prop1"; // STRING [Primary Key]
newEntry.description = undefined; // STRING

propInfoTable.AddRow(newEntry);


// CreateInfoTableFromDataShape
var basicpropInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

// EntityList entry object
var newEntry = new Object();
newEntry.name = "name"; // STRING [Primary Key]
newEntry.description = undefined; // STRING

basicpropInfoTable.AddRow(newEntry);



var result = ThingTemplates["CMOTemplate"].QueryImplementingThingsWithNamedData({
maxItems: undefined /* NUMBER */,
nameMask: undefined /* STRING */,
propertyNames: propInfoTable,
basicPropertyNames: basicpropInfoTable,
query: undefined /* QUERY */,
tags: undefined /* TAGS */
});

 

Hope this helps

Christophe

 

1-Visitor
October 15, 2019

Thank you that was very helpful.