获取不跨用户,迭代和项目获取的缺陷

时间:2012-11-08 18:40:16

标签: javascript rally

我已经研究并尝试了一些我能想到的尝试并检索迭代,项目和用户列的实际值,但我永远无法填充列数据,例如迭代名称,名称项目的名称,以及用户提交的名称。我已经读过,按照我的方式进行抓取应该没问题,其他人说你必须用这样的东西来指定类型

types : ['defect','user','iteration','project'],

当我这样做时,我不会加载我的网格。我按照一些

的推荐尝试过这样的事情
defect.Iteration.Name

OR

Iteration.Name

我真的可以在这里使用一些帮助。我还读了一篇文章说WSAPI不再支持这种请求,必须在多个查询/提取中处理。 Anywho,这是我正在使用的代码......

function onLoad() {
var rallyDataSource = new rally.sdk.data.RallyDataSource(
                '__WORKSPACE_OID__',
                '__PROJECT_OID__',
                '__PROJECT_SCOPING_UP__',
                '__PROJECT_SCOPING_DOWN__');
var config = {
              type : 'defect',
              key  : 'defects',       
              columnKeys : ["FormattedID", "Name", "Priority125", "Iteration", "Project", "SubmittedBy", "CreationDate", "ScheduleState", "State"],
              fetch : 'FormattedID,Name,Priority125,Iteration,Project,SubmittedBy,CreationDate,ScheduleState,State',
              query : '((State != "Closed") OR (ScheduleState != "Accepted"))',
              order : 'Priority125'
              };
var table = new rally.sdk.ui.Table(config, rallyDataSource);
table.display("tableDiv");
}
rally.addOnLoad(onLoad);

1 个答案:

答案 0 :(得分:0)

为了让你的工作变得有用,需要做几件事:

  1. 您可以递归地提取到一个深度。因此,如果您想获取缺陷的名称,格式化ID和项目名称,您的提取将如下所示:
  2. fetch:“Name,FormattedID,Project,Name”
  3. 通过rallyDataSource.findAll()
  4. 获取数据
  5. 对数据进行后处理,以便为表格提供所有字符串数据。即clobber对象参考字段,如Project,改为使用Project Name。
  6. 最后,填充并显示表格。
  7. 这是一个工作示例,说明了我认为您想要做的事情(减去您定义的“优先级125”自定义字段。)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <!-- Copyright (c) 2011  Rally Software Development Corp.  All rights reserved -->
    <html>
    <head>
        <title>Defect Information</title>
        <meta name="Name"    content="Defect Information" />
        <meta name="Version" content="1.32" />
        <meta name="Vendor"  content="Rally Software" />
    
        <script type="text/javascript" src="https://rally1.rallydev.com/apps/1.32/sdk.js?debug=True"></script>
        <script type="text/javascript">
    
            var rallyDataSource = null;
            var table = null;
    
            function showTable(results) {
    
                if (table) {
                    table.destroy();
                }
    
                var tableConfig = {
                    columnKeys   : ["FormattedID", "Name", "Iteration", "Project", "SubmittedBy", "CreationDate", "ScheduleState", "State"],
                    columnWidths : ["85px",        "350px", "90px",      "100px",  "100px",       "120px",         "100px",         "100px" ]
                };
    
               table = new rally.sdk.ui.Table(tableConfig);
    
                // Loop through the rows and clobber object attributes of the results collection with
                // string values
                for(var i = 0; i < results.defects.length; i++){
    
                    thisDefect = results.defects[i];
    
                    var iterationName = "";
                    // Grab value fields
                    if (thisDefect.Iteration != null) {
                        iterationName = results.defects[i].Iteration.Name;
                    } else {
                        iterationName = "Un-scheduled";
                    }
                    var projectName = thisDefect.Project.Name;
    
                    // Re-map SubmittedBy object to SubmittedBy string
                    submittedByDisplayName = thisDefect.SubmittedBy === null ? "": thisDefect.SubmittedBy._refObjectName;                
    
                    // Clober objects with values
                    results.defects[i].Iteration = iterationName;
                    results.defects[i].Project = projectName;
                    results.defects[i].SubmittedBy = submittedByDisplayName;
                }
    
                table.addRows(results.defects);
                table.display(document.getElementById('defectsDiv'));
            }
    
    
            function onLoad() {
                rallyDataSource = new rally.sdk.data.RallyDataSource(
                        '__WORKSPACE_OID__',
                        '__PROJECT_OID__',
                        '__PROJECT_SCOPING_UP__',
                        '__PROJECT_SCOPING_DOWN__');
    
                var config = {
                  type : 'defect',
                  key  : 'defects',       
                  fetch: 'FormattedID,Name,SubmittedBy,Iteration,Name,Project,Name,CreationDate,ScheduleState,State',
                  query : '((State != "Closed") OR (ScheduleState != "Accepted"))',
                };
                rallyDataSource.findAll(config, showTable);
                rallyDataSource.setApiVersion("1.38");
            }
    
            rally.addOnLoad(onLoad);
    
        </script>
    
    </head>
    <body>
    <div id="aDiv"></div>
    <div style="font-weight: bold;"><p>Defects</p></div>
    <div id="defectsDiv"></div>
    </body>
    </html>