Rally SDK Lookback API with Deft Promises Gives Error

25 Views Asked by At

I'm trying to use the Rally Lookback API with Deft Promises. The code below works with wsapi store, but not the snapshot store. Shouldn't the snapshot store work the same? The error received is: TypeError: Cannot read properties of undefined (reading 'getProxy') How to make this work with the snapshot store?

  launch: function() {

     Deft.Promise.all([
        this.loadRecords('UserStory'),
        this.loadRecords('Defect'),
        this.loadRecords('TestCase')
     ]).then({
        success: function(recordSets) {
           // recordSets = [
           //  UserStoryRecords,
           //  DefectRecords,
           //  TestCaseRecords
           // ];
           console.log(recordSets);
        },
        failure: function() {
           //Handle error loading the store here...            
           console.log("Failed.");
        }
     });
  }, // end launch 

  loadRecords: function(model) {
     var deferred = Ext.create('Deft.Deferred');
        // Ext.create('Rally.data.wsapi.Store', {      // This works!
        Ext.create('Rally.data.lookback.SnapshotStore', { // TypeError!!
        limit: 'infinity',
        model: model,
        fetch: ['Name', 'ObjectID'],
        autoload: true                  
     }).load({
        callback: function(records, operation, success) {
           if (operation.wasSuccessful()) {
              deferred.resolve(records);
           } else {
              deferred.reject('Rejected');
           }
        }
     });
     return deferred.promise;
  },
1

There are 1 best solutions below

0
Brian Lee On

So it looks like I found the answer, you don't use model in SnapshotStore requests, pass the name of the data store you want to a _TypeHierarchy filter as such. Below appears to work as expected.

  launch: function() {

     Deft.Promise.all([
        this.loadRecords('HierarchicalRequirement'),
        this.loadRecords('Defect'),
        this.loadRecords('TestCase')
        // do some more stuff
     ]).then({
        success: function(recordSets) {
           // recordSets = [
           //  UserStoryRecords,
           //  DefectRecords,
           //  TestCaseRecords
           // ];
           console.log(recordSets);
        },
        failure: function() {
           //Handle error loading the store here...            
           console.log("Failed.");
        }
     });
  }, // end launch 

  loadRecords: function(model) {
     var deferred = Ext.create('Deft.Deferred');
     Ext.create('Rally.data.lookback.SnapshotStore', {      
        limit: 'infinity',
        // model: model,           // Doesn't work => TypeError
        fetch: ['Name', 'ObjectID'],
        autoload: true,
        filters: [{                          
              property: '_TypeHierarchy',    
              operator: 'in',
              value: [model]       // WORKS!!  
              }]                  
     }).load({
        callback: function(records, operation, success) {
           if (operation.wasSuccessful()) {
              deferred.resolve(records);
           } else {
              deferred.reject('Rejected');
           }
        }
     });
     return deferred.promise;
  }