Skip to main content
12-Amethyst
November 8, 2021
Question

QueryDataTableEntries with TaggedWith does not work

  • November 8, 2021
  • 1 reply
  • 1889 views

I am trying to filter a DataTable using QueryDataTableEntries for a column that contains tags.

According the the documentation I am using this filter expression (where type of field Context is TAGS and Tag type is Model Tags), but the filter does not seem to have any effect:

 

let filters = {
	"filters":
 {
 "type": "NotTaggedWith",
 "fieldName": "Context",
 "tags": "PTC:factory-mv"
 }
};

let result = me.QueryDataTableEntries({
	values: undefined /* INFOTABLE */,
	maxItems: 500 /* NUMBER */,
	tags: undefined /* TAGS */,
	source: undefined /* STRING */,
	query: filters /* QUERY */
});

 

I also tried to get all the data, put it into an Infotable and query that one with the same effect.

 

Can anyone help on this?

 

1 reply

22-Sapphire I
November 8, 2021

I think you are not defining the tag properly for the filter

check out the example in the helpcenter.

http://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/#page/ThingWorx/Help/Composer/Things/ThingServices/QueryParameterforQueryServices.html

 

OCMutz12-AmethystAuthor
12-Amethyst
November 9, 2021

Hi,

this is an exerpt from the help center:

"filters": {
 "type": "And",
 "filters": [
 {
 "type": "GT",
 "fieldName": "Duration",
 "value": "12"
 },
 {
 "type": "TaggedWith",
 "fieldName": "tags",
 "tags": "MaintenanceIssues:PowerOutage"
 }
 ]
 }

 

To me it looks quite similar to what I wrote above exept that I do not have an additional and expression.

22-Sapphire I
November 9, 2021

That's interesting ... I looked at the Help center 8/9 and it has it slightly different, which shows each tag as a JSON pair, maybe try it this way? If this works, then probably need to bug whereever that example came from

var query = {
 "fieldName": "tags",
 "type": "NOTTAGGED",
 "tags": [
 {
 "vocabulary": "Applications",
 "vocabularyTerm": "Testing"
 },
 {
 "vocabulary": "Plants",
 "vocabularyTerm": "Sedona"
 }
 ]
};