April Papajohn
April Papajohn

Reputation: 479

In SDK 2.0rc1 how do I fetch all TeamMembers for a project

This worked fine for me in 2.04p, but in 2.0rc1, it is not getting much data back from the service.

Rally.data.ModelFactory.getModel({
    type : 'Project',
    success : function(project) {

        project.load(projectId, {
            fetch : [ 'TeamMembers','Editors' ],
            callback : callback
        })
    }
});

In 2.04p this got me a list of all the teams in the project (refs, which was all I needed). In 2.0rc1, it just returns me pointers to the desired lists. Looks like I have to send another request to get the actual lists. Is there a param I can pass to this method that will tell it to actually get me the lists of TeamMembers and Editors?

I think that what I am looking for is the SDK equivalent of the API's "Fetch full objects"

Thanks

Upvotes: 1

Views: 248

Answers (1)

April Papajohn
April Papajohn

Reputation: 479

Looks like I just found the answer:

https://help.rallydev.com/apps/2.0rc1/doc/#!/guide/collections_in_v2

For performance reasons it is no longer possible to do this in 2.x versions of WSAPI. Now each object collection has its own unique ref uri. This means these collections can now be separately queried, paged, sorted and filtered. Fetching Defects on a story will now return an object containing the count and the uri from which to retrieve the collection data. The ref uri is generally of the format /type/oid/collection (e.g. /hierarchicalrequirement/12345/defects).

All records now have a getCollection method for retrieving child collection data. This method will return an instance of Rally.data.CollectionStore for working with the child collection. The following example shows how to query stories and then retrieve associated defect information in WSAPI 2.x:

Ext.create('Rally.data.WsapiDataStore', {
model: 'UserStory',
fetch: ['Defects'],
pageSize: 1,
autoLoad: true,
listeners: {
    load: function(store, records) {
        var story = records[0];
        var defectInfo = story.get('Defects');
        var defectCount = defectInfo.Count;

        story.getCollection('Defects').load({
            fetch: ['FormattedID', 'Name', 'State'],
            callback: function(records, operation, success) {
                Ext.Array.each(records, function(defect) {
                    //each record is an instance of the defect model
                    console.log(defect.get('FormattedID') + ' - ' +
                        defect.get('Name') + ': ' + defect.get('State'));
                });
            }
        });
    }
}

});

Upvotes: 2

Related Questions