Rally Software

  • 1.  Retrieving epic name for a user story in javascript

    Posted Jan 26, 2015 11:40 AM
    I am trying to write javascript to list all stories assigned to a specifi iteration. I want to display the epic name that the US is a child of. I am writing this in javascript with the goal to display the info in Confluence. I have all other attributes I need displaying as expected. The js is below.

    var config = { columns: [ {key: 'FormattedIDLink', header: 'ID'}, {key: 'Name', header: 'Name'}, {key: 'OwnerName', header: 'Owner'}, {key: 'ScheduleState', header: 'Schedule State'}, {key: 'PlanEstimate', header: 'Plan Est'}, {key: 'Blocked', header: 'Blocked'}, {key: 'EpicName', header: 'Parent Epic'}],
    type: "hierarchicalrequirement",
    fetch: "Name,FormattedID,Owner,ScheduleState,PlanEstimate,Blocked,Parent",
    query: '(Iteration.Name = "Sprint 15")', };

    var table = new rally.sdk.ui.Table(config, rallyDataSource);
    table.addEventListener(table.getValidEvents().onDataRetrieved, function(t, args)
    {
    rally.forEach(args.items, function(item)
    {
    item.FormattedIDLink = new rally.sdk.ui.basic.Link({"item":item}); item.OwnerName = item.Owner ? item.Owner._refObjectName : "";
    item.EpicName = item.Epic ? item.Epic.Name : "";
    item.Blocked = item.Blocked ? "<img src='https://rally1.rallydev.com/slm/js-lib/rui/builds/rui/resources/css/images/cardboard/blocked-active-icon.png'>":"<img src='https://rally1.rallydev.com/slm/js/rally/resources/images/blocked-icon-white.png'>";
    item.NameTextBox = new rally.sdk.ui.basic.TextBox( {value:item.Name, rememberValue:false});
    item.ScheduleStateDropdown = new rally.sdk.ui.basic.Dropdown( {items: {Backlog:"Backlog", Defined:"Defined", "In-Progress":"In-Progress",Completed:"Completed", Accepted:"Accepted"}, defaultValue: item.ScheduleState, rememberSelection:false}) }); });
     


  • 2.  Re: Retrieving epic name for a user story in javascript

    Posted Jan 26, 2015 07:28 PM
    Hi Elaine,
    In WS API (https://rally1.rallydev.com/slm/doc/webservice/) the attribute on HierarchicalRequirement object (which is user story) that points to a parent(epic) is called Parent, and not Epic.
    Here is a code that outputs names of parent stories of leaf stories scheduled for a given iteration, and a screenshot that I took when testing this app externally, directly in the browser. Notice the similarity of getting to Parent.Name and Project.Name. The difference however is that a story always has a project, so we don't need to check for null, while a story may not have a parent, so we have to check for null.
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
       <title>User Stories By Iteration Example</title>
       <meta name="Name" content="App Example: User Stories Table" />
    
       <script type="text/javascript" src="https://rally1.rallydev.com/apps/1.33/sdk.js"></script>
       <script type="text/javascript">
    
         var rallyDataSource = null;
         var iterDropdown = null;
         var table = null;
         
         function showUserStoriesTable(results) {
    
          for (var i=0; i < results.stories.length; i++) {
                var t = " ";
              if (results.stories[i].Parent){
                   results.stories[i].Parent = results.stories[i].Parent.Name;     
              }
              results.stories[i].Project = results.stories[i].Project.Name;
           }
    
           var tableConfig = {
             columnKeys : ['FormattedID', 'Name', 'Project','Parent' ],
             columnWidths : ['80px', '360px','360px', '400px']
           };
           table = new rally.sdk.ui.Table(tableConfig);
           table.addRows(results.stories);
           table.display(document.getElementById('stories'));
         }
    
        function onIterationSelected() {
           if(table) {
            table.destroy();
           }
           var queryConfig = {
             type : 'hierarchicalrequirement',
             key : 'stories',
            fetch: 'FormattedID,Name,Project,Parent',
             query: '(Iteration.Name = "' + iterDropdown.getSelectedName() + '")',
             order: 'Rank'
          };
           rallyDataSource.findAll(queryConfig, showUserStoriesTable);
         }
    
         function onLoad() {
           // rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__','__PROJECT_OID__','__PROJECT_SCOPING_UP__','__PROJECT_SCOPING_DOWN__');
         rallyDataSource = new rally.sdk.data.RallyDataSource('111','222','true','true');  //IF RUNNING OUSIDE OF RALLY USE OIDs
          var iterConfig = {};
           iterDropdown = new rally.sdk.ui.IterationDropdown(iterConfig, rallyDataSource);
           iterDropdown.display(document.getElementById("iterationDiv"), onIterationSelected);
         }
    
         rally.addOnLoad(onLoad);
      </script>
    
    </head>
    <body>
      <div>
         <div id="iterationDiv"></div>
       </div>
       <br/><br/>
       <div id="stories"></div>
    </body>
    </html>

    0EM140000004iK1
    Please note that you are using a deprecated AppSDK1. I recommend using AppSDK2 (https://help.rallydev.com/apps/2.0rc3/doc/)
    AppSDK1 is also based on no longer supported versions of WS API.
     


  • 3.  Re: Retrieving epic name for a user story in javascript

    Posted Jan 27, 2015 04:26 AM
    Hi Nick - I changed the Epic attribute to Parent and I see the parent for one user story but the Epics for other US are not showing up. The scrrenshot below shows the output of the javascript.0EM140000004iLE

    The screenshot below shows that a US that has no parent displayed in the scrrenshot above but has a parent defined in the US itself.

    0EM140000004iLJ

    I am using the older API as this has support in Confluence via LoginKey. I have not tried out the soluion for rab as yet that you sent last week. I will reply on this in the thread open for this issue.

    Thanks again.


  • 4.  Re: Retrieving epic name for a user story in javascript

    Posted Jan 27, 2015 01:58 PM
    Hi Elaine,
    E877 in your screenshot is not a user story. It is, I assume, a Portfoilo Item, which is a different object. Notice that your user stories have "US" in the prefix as in US5638. Unfortunately UI is deceptive in this regard: it calls both a "parent story" and a "parent portfolio item" a "Parent", which is correct on the intuitive level, and good enough for the UI, but in the Web Services a Parent attribute on the user story object is expected to be another user story.  When writing code, please refer to the Web Services API (https://rally1.rallydev.com/slm/doc/webservice/) documentaton to check the object model.  In a standard workspace, a HierarchicalRequirement (a.k.a user story) has Feature attribute, that is the feature of this Hierarchical Requirement, and  PortfolioItem attribute which is also the Feature parent of this Hierarchical Requirement. You may not have a "Feature" in your workspace: the PortfolioItem types are customizible, and you may have some other first level PortofolioItem type instead of a Feature, and that type in your workspace is using "E" prefix in the FormattedID E877.
    Based on the screenshot it is called Epic, and the full type must be: PortfolioItem/Epic.

    This KnowledgeBase article (https://rallydev.force.com/answers?id=kA0a0000000YdcZ) describes the issue in details, but you would have to replace the stanadrd Feature with your custom PI type.
    Using old AppSDK1 complicates the situation here since the WS API version it is based on is not aware of Portfolio Item types: AppSDK1 predates those. Please see the workaround for that scenario in this KnowledgeBase (https://rallydev.force.com/answers?id=kA0a0000000YcKY) article.
    I am sorry that it is so complex. When you originally mentioned Epic, I assumed you are referring to a parent user story - I could not know that in your workspace you have a custom Epic portfolio item type until I saw the screenshot.