1
votes

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?

1

1 Answers

1
votes

This might not be the issue you're encountering, but if you're running outside Rally, try setting both the Workspace OID and Project OID:

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

When I initially ran your example using Workspace OID only, I found that like you I was not receiving any results, and no errors were returned. However, examining the generated query URL in Chrome's network console:

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

You can see that the User's default project is being passed as the Project parameter. However the PI with that specific ObjectID was in a different Workspace. As an outcome, I was receiving the following error:

{
    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: [ ]
    }
}

Once I included the Project OID in the new-up of rallyDataSource instead of the hangman, I obtained the expected result in the console:

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