Start a new topic

fields method not working when used with Kinvey.Query using backbone SDK

I am trying to use fields method for to fetch only the required fields from a collection using Kinvey.Query(). But when the request is made I am getting an error that the fields method do not exists. Can you please let me know why this is happening, because the documentation for the backbone SDK says that the method exists.

Here is the code snippet that I am using for this - 

/*    name of the kinvey collection    */
var collectionName = ccuName + "System" + seriesName;
/*    preparing the query    */
var query = new Kinvey.Query();
query.greaterThanOrEqualTo('date_time', startDate).lessThanOrEqualTo('date_time', endDate);

/*    creating an instance of common collection for fetching collection data    */
var collection = new cDataCollection({ url: collectionName });
var promise = collection.fetch({
                query   : query,
                success : function(collection, response, options) {
                    console.log('collection fetched successfully');
                    /*    function to parse date time strings    */
                    var parseDate = d3.time.format("%Y-%m-%dT%H:%M").parse;
                    response.forEach(function(d) {
                        d.date_time = parseDate(d.date_time);
                error: function(error) {
                    console.log('some error occurred');

For testing :

collectionName = "ba00ec3cf2268596SystemTS5";

systemGraphParameters = ["operational_mode", "dx_stage1_onoff", "single_zone_mode", "dx_stage2_onoff", "comfort_index", "heat_stage1_onoff", "cm_set_temp", "heat_stage2_onoff", "cm_cur_temp", "fan_stage1_onoff", "cm_humidity", "fan_stage2_onoff", "cm_data_used", "force_fan_status", "cm_dead", "economizer_status", "avg_set_temp", "avg_cur_temp", "env_humidity", "env_temp", "conditioning_mode", "is_vacation_on"];

Good morning Anil,

Can you give me a more exact error that you are getting to make it easier for us to figure out what's happening?

In the interim we will look things over on our end.


When passing an array of field names that needs to be fetched by the Kinvey Query, I am getting this  error when the collection fetch request is made.



We weren't able to recreate this area on our end.   Our engineer Thomas whipped up the following code and executed it without issues.  

var systemGraphParameters = ['operational_mode', 'dx_stage1_onoff', 'single_zone_mode', 'dx_stage2_onoff', 'comfort_index', 'heat_stage1_onoff',
   'cm_set_temp', 'heat_stage2_onoff', 'cm_cur_temp', 'fan_stage1_onoff', 'cm_humidity', 'fan_stage2_onoff', 'cm_data_used', 'force_fan_status',
   'cm_dead', 'economizer_status', 'avg_set_temp', 'avg_cur_temp', 'env_humidity', 'env_temp', 'conditioning_mode', 'is_vacation_on'];
   var query = new Kinvey.Query();
   query.greaterThanOrEqualTo('date_time', 0).lessThanOrEqualTo('date_time', 1);

Please let me know if this helps clarify.


Hi  Damien,

I was getting the same issue, so I checked with the Kinvey SDK version, and it  is fixed. As earlier I was using Kinvey.SDK_VERSION = '1.1.2'. This version I guess is not having the fields method.

Now shifted to Kinvey.SDK_VERSION = '1.3.0', which works well.

Thanks for your time.


No worries, glad you got it fixed :)

Login or Signup to post a comment