Multiple DataTables in return from query
- October 15, 2020
- 1 reply
- 2416 views
Hello, this is my first post here so I hope I am posting in the correct location.
I'm having some issues with figuring out how to do joins and other filter functions on the Thingworx platform.
But I think I am getting the hang of it, at least a little bit.
I am having some issues with while doing an INNER join on two tables from the Operator Advisor addition to TWX.
in the output from my service I get both of the tables "mashed" together. I'll add an attachment to illustrate this.
I think I am getting the join and filter correct, but I am not sure. Here's that code:
var filter = {
"filters": {
"filters": [{
"dataShapeName": "PTC.SCA.SCO.JobOrderProcessingResourceRequirement",
"fieldName": "ProcessingResourceUID",
"type": "EQ",
"value": ProcessingResourceUID
}],
"type": "AND"
},
"joins": [{
"type": "INNER",
"sourceDataShapeName": "PTC.SCA.SCO.JobOrderProcessingResourceRequirement",
"sourceFieldName": "JobOrderUID",
"targetDataShapeName": "PTC.SCA.SCO.JobOrder",
"targetFieldName": "UID"
}]
};
var params = {
filter: filter,
dataShapeName: "PTC.SCA.SCO.JobOrderProcessingResourceRequirement",
};
var result = Things[me.GetDatabaseThingName()].Query(params);
I am trying to use the "ProcessingResourceUID" (which is my input) to get all JobOrders that are related to it through the "JobOrderProcessingResourceRequirement" table.
Output is set to infotable with datashape JobOrder.
Does this look correct to you?
Thanks.

