Reputation: 101
I want to display the initiative and total number of defects raised for the initiative.
Tried with following snippet, but i was not able to relate initiative and the defect.
_getInitiatives: function () {
Ext.create("Rally.data.WsapiDataStore", {
model: "PortfolioItem/initiative",
fetch: ["Project", "Notes", "Name", "Children", "FormattedID"],
limit: 1 / 0,
context: {
project: "/project/xxx",
projectScopeDown: !0,
projectScopeUp: !1
},
autoLoad: !0,
listeners: {
load:this._onDefectsLoaded,
scope: this
}
})
},
_onDefectsLoaded: function(store,data){
this.stories = data;
Ext.create('Rally.data.WsapiDataStore',{
model: 'User Story',
limit: "Infinity",
context: {
project :'/project/xxx',
projectScopeUp: false,
projectScopeDown: true
},
autoLoad: true,
fetch:['FormattedID','Name','Defects','Feature'],
scope:this,
listeners: {
//load: this._onAllDefectsLoaded,
load: this._onDataLoaded,
scope: this
}
});
}
Please provide fix/suggestion for the above mentioned problem
Upvotes: 1
Views: 200
Reputation: 1381
I have found that it is easier to use the Lookback API for requests which reference the RPM, rather than WSAPI. Here is some code which gets all the Initiative records from the project, and then fetches the defect counts for each initiative and applies that count to the record. Hope this helps!
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
Ext.create('Rally.data.lookback.SnapshotStore', {
fetch : ['Name','ObjectID'],
filters : [{
property : '__At',
value : 'current'
},{
property : '_TypeHierarchy',
value : 'PortfolioItem/Initiative'
}]
}).load({
params : {
compress : true,
removeUnauthorizedSnapshots : true
},
callback : function(records, operation, success) {
var me = this;
Deft.Promise.all(Ext.Array.map(records, function(record) {
return me.getInitiativeDefectCount(record.get('ObjectID')).then({
success: function(defectCount) {
record.set('DefectCount', defectCount);
}
});
})).then({
success: function() {
console.log(records);
}
});
},
scope : this
});
},
getInitiativeDefectCount: function(initiativeObjectID) {
var deferred = Ext.create('Deft.Deferred');
Ext.create('Rally.data.lookback.SnapshotStore', {
pageSize : 1,
filters : [{
property : '__At',
value : 'current'
},{
property : '_TypeHierarchy',
value : 'Defect'
},{
property : '_ItemHierarchy',
operator : 'in',
value : initiativeObjectID
}]
}).load({
params : {
compress : true,
removeUnauthorizedSnapshots : true
},
callback : function(records, operation, success) {
deferred.resolve(operation.resultSet.totalRecords);
}
});
return deferred.promise;
}
});
Upvotes: 1