0

I have been looking at the rally Object model, but I can't figure out how to grab the Name attribute of a Defect's Tag.

I made sure to include Tag and Tags in my fetch statement. I am storing all the defects into an array of objects called defectsNEWDEFECTS[]

I can return a Tag object by doing this:

 tagNEWDEFECTS = defectsNEWDEFECTS[i].Tags;
document.write(tagNEWDEFECTS);

which will return this:

[object Object]

But, I can't seem to get it to return the NAME of the tag. I tried:

tagNEWDEFECTS = defectsNEWDEFECTS[i].Tags.Name;
tagNEWDEFECTS = defectsNEWDEFECTS[i].Tags.Tag.Name;
tagNEWDEFECTS = defectsNEWDEFECTS[i].Tag.Name;

But they all return 'undefined'.

Any ideas how to get the name of a tag? Ultimately, the goal here is to have user-input custom tags that I can flag in my program to do certain things. For example, one tag will be named 'RollOverDefect'.

I need to be able to determine which Defects have a Tag called 'RollOverDefect'

Thanks!

4

2 回答 2

1

Tags 是一个集合,因此您最终需要对 Tags 集合属性进行嵌套循环来处理此问题。嵌套到附加循环后,您可以通过以下方式引用标签名称:

tagNEWDEFECTS = defectsNEWDEFECTS[i].Tags[j].Name;

希望这会有所帮助 - 如果可以完成工作,请告诉我们。

于 2013-05-16T20:06:25.417 回答
0

您可能会发现此示例很有用:

<html>
<head>
<title>App Example: Defects with Tags</title>
<meta name="Name" content="App Example: Defects with Tags" />
<meta name="Version" content="2013.2" />
<meta name="Vendor" content="Rally Labs" />
<script type="text/javascript" src="/apps/1.33/sdk.js?apiVersion=1.43""></script>
<script type="text/javascript">

    var table = null;

    function defectsWithTagsExample() {
        var rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__',
            '__PROJECT_OID__',
            '__PROJECT_SCOPING_UP__',
            '__PROJECT_SCOPING_DOWN__'
        );

        function itemQuery() {
            var queryObject = {
                key: 'defects',
                type: 'Defect',
                fetch: 'FormattedID,Name,State,Description,Tags,Name',
                query: '(State = "Submitted")'
            };
            rallyDataSource.findAll(queryObject, populateTable);
        }

        function populateTable(results) {

            if (table) {
                table.destroy();
            }

            var tableDiv = document.getElementById('aDiv');

            var config = {
                'columnKeys'    : ['FormattedID',  'Name',  'Description', 'State',   'Tags'],
                'columnHeaders' : ['FormattedID',  'Name',  'Description', 'State',   'Tags'],
                'columnWidths'  : ['100px',        '400px', '200px',        '85px',   '300px']
            };

            table = new rally.sdk.ui.Table(config);
            table.addRows(results.defects);

            for (i=0;i<results.defects.length;i++) {

                myDefect = results.defects[i];
                myTags = results.defects[i].Tags;
                myTagString = "";

                for (j=0;j<myTags.length;j++) {
                    myTag = myTags[j];
                    myTagName = myTags[j].Name;
                    if (j == 0) {
                        myTagString += myTagName;
                    } else {
                        myTagString += ", " + myTagName;
                    }
                }

                linkConfig = {item: {FormattedID: myDefect.FormattedID, "_ref" : myDefect._ref}};
                defectLink = new rally.sdk.ui.basic.Link(linkConfig);

                table.setCell(i, 0, defectLink.renderToHtml());
                table.setCell(i, 4, myTagString);
            }

            table.display(tableDiv);

        };

        itemQuery();
    }

    rally.addOnLoad(defectsWithTagsExample);
</script>
</head>
<body>
<div id="aDiv"></div>
</body>
</html>
于 2013-05-17T22:15:43.310 回答