cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Combine two queries or force value in data filter widget.

mateuszboc
1-Newbie

Combine two queries or force value in data filter widget.

Hi,

I would like to combine two queries.


Use case: I've got boolean field in my stream, and I want to display on some charts only data where this boolean is true. So my default query for some service is like: {"filters":{"expression":"true","type":"Matches","fieldName":"Valid"}}. But when user define his own query using DataFilter widget, than he is able to see all valid and invalid data as long as he manually don't check valid = true in DataFilter widget. 


I was trying to write my own service for joining two queries but Query object behaves strangely - it lacks functions like 'push' for Array objects 


ex.

query = {   "filters": {     "type": "AND",     "filters": [       {         "fieldName": "Complex1",         "type": "NE",         "value": 30       },       {         "fieldName": "Complex2",         "type": "EQ",         "value": 1       }     ]   } };


when I code: 

query.filters.filters.push( whatever ) I get an Error:  Cannot find function push in object . (joinQuery#72).


Is there any place where I can find documentation of prototype functions available for different TW build-in objects?

Is there any snippet for joining Queries?

Is there any way to force DataFilter widget to set value always to true/false?



2 REPLIES 2

Did you ever find an answer to this question?

Consider a custom service which accepts a user's query, and also applies the "Valid=true" query to build the result.

var valid = {"filters":{"expression":"true","type":"Matches","fieldName":"Valid"}};

var result = me.QueryStreamEntriesWithData({ query : valid });

if(userQuery) result = Resources.InfoTableFunctions.Query({ t : result, query : userQuery });

Then, bind the mashup to use this service instead of the built-in QueryStreamEntriesWithData (or similar).

Top Tags