Rally SDK 2.0 - Multi-Type Artifact Filtering

I am trying to get a combined set of records from User & Defect History. I have filters for each of them (e.g. Defect State! = Closed and User Story Direct Child Count = 0), but I cannot execute a combined query or custom query that will work. For example, the following code returns User Stories, but inherently filters out all defects.

I'm sure there are several ways to do this, but how do you get a combined set of results from multiple types with filters specific to each type? Thank.

_getData: function(name) {
    var deferred = Ext.create('Deft.Deferred');

    Ext.create('Rally.data.wsapi.artifact.Store', {
        models: ['UserStory', 'Defect'],
        pageSize: 2000,
        fetch: ['c_MyCustomField', 'ScheduleState', 'PlanEstimate', 'Name'],
        filters: [
            { property: 'ScheduleState', operator: '!=', value: 'Accepted' },
            function(item){
                var dirChildCountIsGood = false;
                try
                {
                    if (item.DirectChildrenCount > 0)
                        dirChildCountIsGood = false;
                }
                catch(ex) {}
                return false;
            },
            /* or */{ property: 'DirectChildrenCount', operator: '=', value: '0' }
            //{ property: 'State', operator: '!=', value: 'Closed' }
        ],
        sorters: [
            { property: 'c_MyCustomField', direction: 'ASC'} // Same field for both User Stories and Defects
        ],
        autoLoad: true,
        listeners: {
            scope: this,
            load: this._onRecordsLoaded
        }
    });
    console.log('Call to WSAPI store complete.');
    return deferred;
}

      

+3


source to share


1 answer


This is an unfortunate oddity with an artifact endpoint. You can work around this by using a special hidden TypeDefOid attribute in your request to force the different clauses to only apply to the correct types. In the long term, we hope to improve the WSAPI query language to better support this type of scenario.

Create two filters:

var nonClosedDefectsFilter = Rally.data.wsapi.Filter.and([
    {
        property: 'TypeDefOid',
        value: 12345 //replace with your defect typedef oid
    }, 
    {
        property: 'State',
        operator: '!='
        value: 'Closed'
    }
]);

var leafStoryFilter = Rally.data.wsapi.Filter.and([
    {
        property: 'TypeDefOid',
        value: 23456 //replace with your story typedef oid
    }, 
    {
        property: 'DirectChildrenCount',
        value: 0
    }
]);

      



And then, or both, when you pass them to your store during creation:

Ext.create('Rally.data.wsapi.artifact.Store', {
    //other config from above omitted for brevity
    filters: [nonClosedDefectsFilter.or(leafStoryFilter)]
});

      

+1


source







All Articles