Rally Software

  • 1.  Retrieving all workspaces within a Subscription

    Posted Oct 25, 2018 07:14 AM

    Can I use the Rally SDK to iterate through all the workspaces in my Subscription?  I am using the code below, but it only returns the workspace of my current context.  I am trying to create an app to list all the projects within all the workspaces in our Subscription.  Thanks in advance!

     

    _getworkSpaces : function (){
    // Get workspaces
    Ext.create('Rally.data.wsapi.Store', {
       model: 'Workspace',
       autoLoad: true,
       limit: Infinity,
       sorters: [
          { property: 'Name',direction: 'ASC' }
       ],
       scope: app,
       filters: [
          {
             property: 'State',
             operator: '=',
             value: 'Open'
          }
       ],
       listeners: {
          load: function(store, data, success) {

             console.log(data);

        }
       },
          fetch: ['Name','State']
       });
    }



  • 2.  Re: Retrieving all workspaces within a Subscription
    Best Answer

    Broadcom Employee
    Posted Oct 25, 2018 02:56 PM

    Hi Stephen,

     

    The 'Workspace' model is limited to fetching one workspace. You can either specify one or otherwise it will default to the defaultWorkspace of the user who owns the api-key you're using.

     

    To get a list of your Subscription's workspaces, you shall use the Subscription model, then fetch and use the 'workspaces' collection.

     

    Here is a sample code that works. You can see it's fetching the 'workspaces' collection. You can see it then iterates over the 'records' and writes to the console the Name and State of each workspace.  For some reason I'm still struggling with displaying it on the grid, but I don't want to to delay my reply to you cause it's irrelevant to your challenge. The data that's returned by this sample below is working and correct. I'm bolding the elements the demonstrate what I just explained:

     

     

    Ext.create('Rally.data.wsapi.Store', {
       model: 'Subscription',
       fetch: ['Name', 'Workspaces'],
       autoLoad: true,
       listeners: {
          load: function(store, records) {
          var subscription = records[0];
          console.log('subscription.Name = ' + subscription.get('Name'));
          var WorkspacesCollection = subscription.get('Workspaces');
          var WorkspaceCount = WorkspacesCollection.Count;
          console.log('WorkspaceCount = ' + WorkspaceCount);

     

             subscription.getCollection('Workspaces').load({
                fetch: ['Name', 'State'],
                callback: function(records, operation, success) {
                   Ext.Array.each(records, function(workspace) {
                      console.log(workspace.get('Name') + ': ' + workspace.get('State'));
                   });

                   app._loadGrid(records);
                }
             });


          }
       }
    });

     

     

    Let us know if that helped.

     

    Sagi



  • 3.  Re: Retrieving all workspaces within a Subscription

    Broadcom Employee
    Posted Oct 26, 2018 12:20 PM

    Hi Stephen,

     

    I fixed that excerpt code to get the whole thing to work. The essence is what I had explained in my previous reply.

    Attached the javascript file.

     

    We hope we answered your question, please let us know.

     

    Thanks,

    Sagi



  • 4.  Re: Retrieving all workspaces within a Subscription

    Posted Oct 26, 2018 03:22 PM

    That worked!  Thanks for your help.



  • 5.  Re: Retrieving all workspaces within a Subscription

    Broadcom Employee
    Posted Oct 26, 2018 03:34 PM

    Good deal