Rally SDK 2.0 - Multi-type artifact filtering

ChrisS

I'm trying to get a combined record set from User Stories and Defects. I have filters for each that work (e.g. Defect State != Closed and User Story Direct Child Count = 0) but I'm unable to have a combined query or custom query that will work. For example, the following code brings back User Stories but inherently filters out all defects.

I'm sure there are multiple ways of doing this but how do you get a combined result set of multiple types with filters specific for each type? Thanks.

_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;
}
Kyle Morse

This is an unfortunate weirdness with the artifact endpoint. You can work around it by using a special hidden TypeDefOid attribute in your query to get the various clauses to only apply to the correct types. Longer term we hope to make enhance the WSAPI query language to better support this type of scenario.

Build two filters like so:

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 them together when you pass them to your store at creation time:

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Create custom Argo artifact type

From Dev

How do I get PortfolioItem results in Rally SDK1.33?

From Dev

Rally app SDK 2.0rc1 - Uncaught ReferenceError: rally is not defined

From Dev

Building Rally Apps Intro to 2.0 SDK

From Dev

SDK: filtering a rallycardboard

From Dev

create/update user story using rally app sdk

From Dev

Updating iteration for story using Rally SDK

From Dev

Rally App SDK 2.0 - filter by date

From Dev

Multi-Dimensional Filtering

From Dev

Filter function for wsapi store not working in Rally SDK

From Dev

In Rally SDK, show hidden fields in UI components

From Dev

Rally SDK 2 custom sorters

From Dev

Rally SDK2.0 RC3 Query

From Dev

Rally SDK external development Rally.environment undefined

From Dev

maven multi-module artifact deployment

From Dev

Can I masquerade as another user when creating/updating Rally artifact using Rally WSAPI?

From Dev

Rally sdk - get list of tasks from a story object

From Dev

Does SDK 2.0 work outside of Rally?

From Dev

Rally SDK 2.0 displaying debug information

From Dev

Rally SDK2 how to override the row CSS

From Dev

HTML Table multi column filtering

From Dev

Upgrading my Rally app from rally SDK 1.32 to rally SDK 2.0p5

From Dev

maven multi-module artifact deployment

From Dev

Rally Query in the SDK 1 vs Store in the SDK 2

From Dev

filtering multi select dropdown options

From Dev

XSLT Multi level Filtering syntax

From Dev

Adding a picture to Rally artifact by using Pyral

From Dev

Filtering multi-dimensional array

From Dev

Filtering list with multi criterias