问题
Here is the API verison I am using:
script type="text/javascript" src="/apps/1.33/sdk.js?apiVersion=1.43"></script>
The goal is to display a portfolio item/feature and all the child user stories of the feature in a grid. Then based on the US fields value, update the value of the field of the portfolio item/feature.
I am able to update the release field of a UserStory using rallydatasource.update
command, but the same command doesn't work for updating fields of portfolio item/feature
Here are the fields I am trying to update for Feature
. These do not work
rallyDataSource.update({_ref:ref, GroomingState: nfGroomingState},onUpdateComplete,onError);
rallyDataSource.update({_ref:ref, c_GroomingState: nfGroomingState},onUpdateComplete,onError);
rallyDataSource.update({_ref:ref, Ready: true},onUpdateComplete,onError);
rallyDataSource.update({_ref:ref, Notes: "This is test"},onUpdateComplete,onError);
rallyDataSource.update({_ref:ref, Architect: "XYZ ABC"},onUpdateComplete,onError);
Here are the fields I am trying to update for UserStory
. This does work.
rallyDataSource.update({
"_ref":sRef,
"Release": [
{
ref:relRef
}
]},
onUpdateComplete,onError);
Can someone please help me understand if there is something I am doing wrong? Is update to portfolio item not supported in v 1.43?
回答1:
You are using a trick ?apiVersion=1.43
to set the WS API version to the version the legacy AppSDK1 predates and does not support, and it works to the extent but not enough to get the updates working.
I suggest AppSDK2
Also, since State of PI types is a full object (unlike State or ScheduleState of Defects or UserStories) a _ref has to be used in this code: GroomingState: nfGroomingState
You may be using the reference, it was not clear from the code fragment. There is a Ruby example here that works with PI states. Rally Ruby toolkit sits on the same WS API model, so that example is not entirely irrelevant.
Here are the details of what I tried with AppSDK1 set to use version 1.43 of WS API.
Regardless how I set the version either using src="/apps/1.33/sdk.js?apiVersion=1.43"
or rallyDataSource.setApiVersion("1.43");
I have to use parent type:
PortfolioItem
instead of concrete PortfolioItem/Feature
type when I query:
function itemQuery() {
var queryObject = {
key: "pi",
//type: "PortfolioItem/Feature", //does not work
type: "PortfolioItem",
fetch: "FormattedID,Parent,State,Name",
query: "(Parent.FormattedID = I8)"
};
rallyDataSource.findAll(queryObject, populateTable);
}
This works fine, and all children of PortfolioItem/Initiative I8, which are of type PortfolioItem/Feature are returned successfully, and if all I want to do is to build a grid, it works:
function populateTable(results) {
var tableDiv = document.getElementById('aDiv');
for (var i=0; i < results.pi.length; i++) {
var config = { columns:
[{key: 'FormattedID', header: 'Formatted ID', width: 100},
{key: 'State.Name', header: 'State', width: 100},
]};
var table = new rally.sdk.ui.Table(config);
table.addRows(results.pi);
table.display(tableDiv);
};
Two features are returned, one that has State already set, the other with no State:
However if I try to add the update function:
function populateTable(results) {
var tableDiv = document.getElementById('aDiv');
for (var i=0; i < results.pi.length; i++) {
if(results.pi[i].State === null){
console.log('state:',results.pi[i].State)
rallyDataSource.update({"_ref":results.pi[i]._ref, "State": "https://rally1.rallydev.com/slm/webservice/v2.0/state/12352608621"});
}
}
//...
"Requested type name "feature" is unknown
error is returned:
OperationResult: ObjectErrors: Array[1]0: "Requested type name "feature" is unknown."length: 1__proto__: Array[0]Warnings: Array[1]0: "Please update your client to use the latest version of the API. You can find the latest version at https://rally1.rallydev.com/slm/doc/webservice/index.jsp?version=v2.0. No new projects should use this version of the API as it will be removed in the future."length: 1
AppSDK1 works with WS API that is no longer supported. Last supported date for 1.43 was June 20 of this year. AppSDK1 stopped at 1.32 of WS API. That is the reason for the trick to set WS API version because PortfolioItems were introduced in 1.37 of WS API. Particularly when you use features introduced after AppSDK1 was no longer updated (see WS API versioning) there is no guarantee that the rallyDataSource.setApiVersion("1.43");
trick will work in all scenarios.
来源:https://stackoverflow.com/questions/26048290/rallydatasource-update-is-not-working-for-portfolioitem-feature-works-for-users