7 Replies Latest reply on Nov 25, 2015 8:57 AM by qn RSS
    roberttay Apprentice

    Can't get ThingTemplate.QueryImplementingThingsWithData(...) to work with Query filter


    I'm trying to query for implementing things on a template which have certain property values.

    I'm doing this in Java.

    Here is an example:

    ThingTemplate template = // get thing template

    String property1Value = "someValue";

    String property2Value = "anotherValue";

    JSONArray a = new JSONArray();

      a.push(newFilterJSONObject("EQ", "property1", property1Value));

      a.push(newFilterJSONObject("EQ", "property2", property2Value));

      JSONObject filters = new JSONObject();

      filters.put("type", "AND");

      filters.put("filters", a);


    InfoTable results = template.QueryImplementingThingsWithData(500.00, null, null, filters);


    This will return all implementing things as if it is ignoring the filter.


    I've reviewed the Query docs and am using the composite query example:

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



    This is the resulting JSON from the Java JSONObject above:



    1. {},
      • "fieldName":"property1",
      • "type":"EQ",
      • "value":"1"
    2. {}
      • "fieldName":"property2",
      • "type":"EQ",
      • "value":"1"





    There are no matches in my data so i should be getting back an empty InfoTable, but i'm not.


    What am i doing wrong?