htmlrally

Need Rally HTML to return url instead of string for attachment


I'm using custom html for a rally app to query and return a list of objects with their attachments. Works well for what I'm doing, but although on screen in Rally I can click the name and it's a link to the attachment, when I grab the list and paste it into excel I end up with just the name of the attachment and I really need a link to the attachment.

Can anyone help me with this html so that it returns the actual url in Rally rather than the name with the url behind it? See these imagesenter image description here. The top represents the current results whereas the bottom represents the desired results.

     <html>
        <head>
           <title>Story Table</title>
           <meta name="Name" content="Stories with Attachments" />
           <meta name="Version" content="2014.2" />
           <meta name="Vendor" content="Rally Software" />
       <script type="text/javascript" src="https://rally1.rallydev.com/apps/1.32/sdk.js"></script>
       <script type="text/javascript">
             var table = null;

             function tableExample() {
               var rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__',
                                                                                    '__PROJECT_OID__',
                                                                                    '__PROJECT_SCOPING_UP__',
                                                                                    '__PROJECT_SCOPING_DOWN__');
              function itemQuery() {
                 var queryObject = {
                   key: 'theItems',
                   type: iType,
                   fetch: 'FormattedID,Name,State,ScheduleState,Description,Attachments,ObjectID',
                   query: Qvalue
                 };
                 rallyDataSource.findAll(queryObject, populateTable);
              }
              function populateTable(results) {
                  if (table) {
                      table.destroy();
                  }
                  var col3 = 'ScheduleState';
                  if (iType == 'task') {
                    col3 = 'State';
                  }
                 var tableDiv = document.getElementById('aDiv');
                 var config = { 'columnKeys'    : ['FormattedID',  'Name', col3,   'Attachments'],
                                'columnHeaders' : ['FormattedID',  'Name', col3,   'Attachments'],
                                'columnWidths'  : ['100px',        '400px', '85px',           '300px']
                               };
                 table = new rally.sdk.ui.Table(config);
                 table.addRows(results.theItems);
                 for (i=0;i<results.theItems.length;i++) {
                     myStory = results.theItems[i];
                     myStoryURL = rally.sdk.util.Context.getServerInfo().getUrl()+"/#/" + '__PROJECT_OID__' + "/detail/"+ iType + "/"+myStory.ObjectID;
                     myStoryHTML = "<div><a href='" + myStoryURL + "' target='_top'> " +
                                 myStory.FormattedID + "</a></div>";
                     myAttachments = results.theItems[i].Attachments;
                     myAttachmentHTML = "";
                     for (j=0;j<myAttachments.length;j++) {
                         myAttachmentOID = myAttachments[j].ObjectID;
                         myAttachmentName = myAttachments[j].Name;
                         myAttachmentURL = rally.sdk.util.Context.getServerInfo().getSlmUrl()+"/attachment/"+
                                 myAttachmentOID + "/" + myAttachmentName;

                         myAttachmentHTML += "<div><a href='" + myAttachmentURL + "'>" +
                                 myAttachmentName + "</a></div>";

                     }
                     table.setCell(i, 3, myAttachmentHTML);
                     table.setCell(i, 0, myStoryHTML);
                 }
                 table.display(tableDiv);
              };
              itemQuery();
             }
             rally.addOnLoad(tableExample);
            </script>

            <script type="text/javascript">
                var Qvalue = '';
                function textBoxChanged(tb, args) {
                    Qvalue = args.value;
                }
                function Qbox() {
                    var config = {
                        label : 'Query String: ',
                        value : '',
                        width: 500,
                        showLabel: true
                    };
                    var textBox = new rally.sdk.ui.basic.TextBox(config);
                    textBox.display("textbox", textBoxChanged);
                }
                rally.addOnLoad(Qbox);
            </script>
            <script type="text/javascript">
                var iType = 'hierarchicalrequirement';
                function typeSelect() {
                function onChanged(c, args) {
                    iType = args.value;
                }
                var config = {
                    radios: [{label:"Stories", value:"hierarchicalrequirement"},{label:"Defects",value:"defect"},{label:"Tasks",value:"task"},{label:"Test Cases",value:"testcase"}],
                    labelPosition: "after",
                    rememberChecked: false,
                    defaultValue: "hierarchicalrequirement", 
                    groupName: "itemTypes"
                };
                var radioButtonGroup = new rally.sdk.ui.basic.RadioButtonGroup(config);
                radioButtonGroup.display("itemGroup", onChanged);
                }
                rally.addOnLoad(typeSelect);
            </script>
</head>
    <body>
        <p><div id="itemGroup"></div><span id="textbox"></span>
        <button onclick="tableExample()">Refresh</button>
            <a href="http://www.rallydev.com/help/grid-queries" target="_blank">Query Help</a>
        <br></p>
        <div id="aDiv" style="overflow-y: auto;"></div>
    </body>
</html>

Solution

  • I'm assuming you still want to be able to click on the attachment links within the app.

    So try replacing this line of code:

    myAttachmentHTML += "<div><a href='" + myAttachmentURL + "'>" + myAttachmentName + "</a></div>";
    

    With this:

    myAttachmentHTML += "<div><a href='" + myAttachmentURL + "'>" + myAttachmentURL + "</a></div>";