1

I am using the Rally SDK1.33 as in the end I need to display information using the LoginKey outside of Rally. I am trying to query information on PortfolioItem, but it looks like no results are being returned. - However if I put the query in the through the webservice doc pages, I get a result.

Using the following link (replacing 123456789 with a real ObjectID for a PortfolioItem and the workspace 987654321 with a real workspace) I get back the PortfolioItem object:

https://rally1.rallydev.com/slm/webservice/1.43/portfolioitem.js?workspace=https://rally1.rallydev.com/slm/webservice/1.43/workspace/987654321&query=(ObjectID%20%3D%20123456789)&fetch=true&start=1&pagesize=20

However if I try to query it from code, I get back the query results without any results and without any errors (again - using a real PortfolioItem ObjectID instead of the 123456789).

ExternalPortfolio

<!--App information-->
<meta name="Name" content="App: ExternalPortfolio"/>
<meta name="Version" content="1.0"/>
<meta name="Vendor" content=""/>

<!--Include SDK-->
<script type="text/javascript" src="https://rally1.rallydev.com/apps/1.33/sdk.js?debug=true&apiVersion=1.43"></script>


<script type="text/javascript">

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

        var objectId = 123456789;

        var queryConfig = { 
                type: 'PortfolioItem',
                key: 'portfolio',
                fetch: 'FormattedID,Name',
                query: '(ObjectID = ' + objectId +')'
               };

        rallyDataSource.findAll(queryConfig, showPortfolio, errorCallBack);  

        function showPortfolio(results) {
            console.log(results);
        }

        function errorCallBack(response) {
        console.log('Got problems!')
        console.log(response.Errors);
        console.log(response.Warnings);
        }   
    }

    rally.addOnLoad(onLoad);


</script>

<style type="text/css">

    .externalPortfolio {
        /* Add app styles here */
    }

</style>

I have created a number of reports on Stories and Defects (most all running outside of Rally), but never for a PortfolioItem. - Am I missing something here? Or is there a severe bug with the v1.xx SDK or v1.x API in handling portfolio items?

4

1 回答 1

1

这可能不是您遇到的问题,但如果您在 Rally 之外运行,请尝试同时设置Workspace OID 和 Project OID:

    rallyDataSource = new rally.sdk.data.RallyDataSource(
                                              '12345678910', 
                                              '12345678911',
                                              '__PROJECT_SCOPING_UP__', 
                                              '__PROJECT_SCOPING_DOWN__');

当我最初仅使用 Workspace OID 运行您的示例时,我发现和您一样,我没有收到任何结果,也没有返回任何错误。但是,在 Chrome 的网络控制台中检查生成的查询 URL:

https://rally1.rallydev.com/slm/webservice/1.43/adhoc.js?_method=POST&adHocQuery={"portfolio":"/portfolioitem?query=(ObjectID = \"152345647\")&pagesize=200&fetch=FormattedID,Name&workspace=/workspace/12345678910&project=${/user/userprofile/defaultProject}&projectScopeUp=false&projectScopeDown=true"}&jsonp=dojo.io.script.jsonp_dojoIoScript1._jsonpCallback

您可以看到用户的默认项目正在作为 Project 参数传递。但是,具有该特定 ObjectID 的 PI 位于不同的工作区中。结果,我收到以下错误:

{
    portfolio: {
        _rallyAPIMajor: "1",
        _rallyAPIMinor: "43",
        Errors: [
            "The specified project must be in the specified workspace. Project OID=12345678921 is in Workspace OID=1234569840 and the specified Workspace is OID=12345678910."
        ],
        Warnings: [ ],
        _ref: "/portfolioitem?query=(ObjectID = "152345647")&pagesize=200&fetch=FormattedID,Name&workspace=/workspace/12345678910&project=/project/12345678921&projectScopeUp=false&projectScopeDown=true",
        TotalResultCount: 0,
        StartIndex: 0,
        PageSize: 0,
        Results: [ ]
    }
}

一旦我将 Project OID 包含在 new-uprallyDataSource而不是 hangman 中,我在控制台中获得了预期的结果:

Object {errors: Array[0], warnings: Array[0], portfolio: Array[1]}
errors: Array[0]
portfolio: Array[1]
0: Object
DirectChildrenCount: 0
FormattedID: "F10"
Name: "PI Feature 10"
_objectVersion: "7"
_rallyAPIMajor: "1"
_rallyAPIMinor: "43"
_ref: "https://rally1.rallydev.com/slm/webservice/1.43/portfolioitem/feature/152345647.js"
_refObjectName: "PI Feature 10"
_type: "PortfolioItem/Feature"
__proto__: Object
length: 1
__proto__: Array[0]
warnings: Array[0]
__proto__: Object
于 2013-10-26T17:39:02.043 回答