Telerik Everlive Multiple Queries in one Query

219 Views Asked by At

How can I use .or() with .and() in a Everlive query? I basically want the results of (JobNumber && PhoneNumber) || (JobNumber && wgnumber). Thank you.

My attempt:

var query = new Everlive.Query();
query.where()
        .and()
        .eq('JobNumber', this.get("job_number"))
        .eq('PhoneNumber', this.get("phone_wgn_number"))
        .or()
        .eq('wgnumber', this.get("phone_wgn_number"))
.done();
1

There are 1 best solutions below

0
On

I got the answer from Telerik's support:

var api_key = "XXXXXXXXXXXXXXXX";
var el = new Everlive(api_key);
var query = new Everlive.Query();
query.where()
    .or()
        .and()
            .eq('PARAM_1', PARAM_1_VALUE)
            .eq('PARAM_2', PARAM_2_VALUE)
            .done()
        .and()
            .eq('PARAM_3', PARAM_3_VALUE)
            .eq('PARAM_4', PARAM_4_VALUE)
            .done();
var data = el.data('TYPE_NAME');
data.get(query)
.then(function (data) {
    var json_data_str = JSON.stringify(data);
    console.log("search_wg_phone_number >> " + json_data_str);
    var json_data = JSON.parse(json_data_str);
    if (json_data.count == 1) { }
    else { }
},
function (error) {
    var json_data_str = JSON.stringify(error);
    console.log(json_data_str);
    var json_data = JSON.parse(json_data_str);
    var responseText = json_data["responseText"];
    var json_data_responseText = JSON.parse(responseText);
    var message = json_data_responseText["message"];
    console.log(message);
});

Make sure you include their header:

<script src="https://bs-static.cdn.telerik.com/latest/everlive.all.min.js"></script>