Sonalkumar sute
Sonalkumar sute

Reputation: 2575

filters not working on specific workspace rally

I have two workspaces When I load my application on one workspace it works with the filters but when I use same code it doesn't work. Then I tried commenting out filters then it gave me whole records. Not able to figure what's the difference, I am using Rally sdk2.0rc3 below are my code snippet

this._startDate value is 2014-09-10

this._endDate value is 2015-03-03

and when I print operation it gives false

and iterations = []

@nickm help me

            _onDataLoaded: function() {
                console.log("this.getContext().getProject()._ref", this.getContext().getProject()._ref);
                console.log("this._startDate", this._startDate);
                console.log("this._endDate", this._endDate);
                var project_oid = this.getContext().getProject()._ref;

                var startDateFilter = Ext.create('Rally.data.QueryFilter', {
                    property: 'StartDate',
                    operator: '>',
                    value: this._startDate
                });
                startDateFilter = startDateFilter.and({
                    property: 'StartDate',
                    operator: '<',
                    value: this._endDate
                });
                startDateFilter = startDateFilter.and({
                    property: 'StartDate',
                    operator: '!=',
                    value: null
                });
                var endDateFilter = Ext.create('Rally.data.QueryFilter', {
                    property: 'EndDate',
                    operator: '<',
                    value: this._endDate
                });
                endDateFilter = endDateFilter.and({
                    property: 'EndDate',
                    operator: '>',
                    value: this._startDate
                });
                endDateFilter = endDateFilter.and({
                    property: 'EndDate',
                    operator: '!=',
                    value: null
                });
                var filter = startDateFilter.or(endDateFilter);
                //filter.toString();
                Ext.create('Rally.data.WsapiDataStore', {
                    model: 'Iteration',
                    limit: Infinity,
                    context: {
                        project: project_oid,
                        projectScopeDown: true,
                        projectScopeUp: false
                    },                          
                    fetch: ['Name','Project', 'StartDate', 'EndDate', 'Parent', 'Children'],
                    autoLoad: true,
                    filters: [
                        filter
                    ],
                    listeners: {
                        load: this._loadGrid,
                        scope:this
                    }                   
                }, this);   
            },
            _loadGrid: function(store, iterations, operation) {
                console.log("hi there", operation);

Upvotes: 1

Views: 233

Answers (1)

nickm
nickm

Reputation: 5966

My first guess was that if the same code works in one workspace and does not work in another workspace, and the culprit is the filter based on date values, check if your workspaces have different date format. For example like this:

enter image description here

or like this:

enter image description here

But I tested '2015-02-06' value in a workspace that using mm/dd/yyyy format and it worked.

In any case, if it works in one workspace and does not work in another chances are this is not an issue with the code but with the data. Maybe in the second workspace the same query returns 0 results. Also, depending on the meaning of the dates used in code, it is possible to avoid hard-coding dates. For example, to get current iteration try this:

var today = new Date().toISOString();
filters: [
                {
                    property: 'StartDate',
                    operator: '<=',
                    value: today
                },
                {
                    property: 'EndDate',
                    operator: '>=',
                    value: today
                }
            ]

Upvotes: 1

Related Questions