所以我試圖同步功能的自定義字段與其子故事的(史詩的)自定義字段值。拉力賽:從史詩故事的objectid檢索功能objectid
在將值寫入史詩的自定義字段之後,我需要調用一個將相同值寫入功能的自定義字段的函數。我需要幫助根據史詩故事的目標檢索特徵的ObjectID。
另外,我正在使用Rally SDK 2.0p5。
所以我試圖同步功能的自定義字段與其子故事的(史詩的)自定義字段值。拉力賽:從史詩故事的objectid檢索功能objectid
在將值寫入史詩的自定義字段之後,我需要調用一個將相同值寫入功能的自定義字段的函數。我需要幫助根據史詩故事的目標檢索特徵的ObjectID。
另外,我正在使用Rally SDK 2.0p5。
以下是更新故事的自定義字段,然後更新其父級要素的自定義字段的示例。在此代碼中,首先創建一個新故事,其PortfolioItem屬性設置爲從工作區中存在的功能填充的組合框中選擇的功能。請注意,在WS API中,HierarchicalRequirement對象具有Feature屬性和PortfolioItem屬性,但前者是隻讀屬性,因此後者必須用於更新故事的父級PI/Feature。在創建故事並設置其父功能後,其自定義字段將更新,並且最後會更新父功能的自定義字段。
您可能會看到this github repo中的html文件。
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
if (this.down('#features')) {
this.down('#features').destroy();
}
var features = Ext.create('Rally.ui.combobox.ComboBox',{
id: 'features',
storeConfig: {
model: 'PortfolioItem/Feature',
fetch: ['FormattedID','Name', 'UserStories'],
pageSize: 100,
autoLoad: true,
},
fieldLabel: 'select Feature',
listeners:{
ready: function(combobox){
if (combobox.getRecord()) {
this._onFeatureSelected(combobox.getRecord());
}
},
select: function(combobox){
if (combobox.getRecord()) {
this._onFeatureSelected(combobox.getRecord());
}
},
scope: this
}
});
this.add(features);
},
_onFeatureSelected: function(feature){
var that = this;
if (this.down('#b')) {
this.down('#b').destroy();
}
var cb = Ext.create('Ext.Container', {
items: [
{
xtype : 'rallybutton',
text : 'create',
itemId: 'b',
handler: function() {
that._getModel(feature);
}
}
]
});
this.add(cb);
},
_getModel: function(feature){
var that = this;
Rally.data.ModelFactory.getModel({
type: 'UserStory',
success: function(model) {
that._model = model;
var story = Ext.create(model, {
Name: 'story 777',
Description: 'created via appsdk2'
});
story.save({
callback: function(result, operation) {
if(operation.wasSuccessful()) {
console.log("_ref",result.get('_ref'), ' ', result.get('Name'));
that._record = result;
that._readAndUpdateStory(feature);
}
else{
console.log("?");
}
}
});
}
});
},
_readAndUpdateStory:function(feature){
var that = this;
var id = this._record.get('ObjectID');
this._model.load(id,{
fetch: ['Name', 'FormattedID', 'ScheduleState', 'PortfolioItem', 'StoryCustomField'],
callback: function(record, operation){
console.log('ScheduleState prior to update:', record.get('ScheduleState'));
record.set('ScheduleState','In-Progress');
record.set('PortfolioItem', feature.get("_ref"));
record.set('Project', '/project/12352608219');
record.set('StoryCustomField', 'one');
record.save({
callback: function(record, operation) {
if(operation.wasSuccessful()) {
console.log('ScheduleState after update..', record.get('ScheduleState'));
console.log('StoryCustomField after update..', record.get('StoryCustomField'));
console.log('The Feature parent of this story after update..', record.get('PortfolioItem'));
that._readAndUpdateFeature(feature);
}
else{
console.log("?");
}
}
});
}
})
},
_readAndUpdateFeature:function(feature){
var id = feature.get('ObjectID');
Rally.data.ModelFactory.getModel({
type: 'PortfolioItem/Feature',
success: function(model) {
model.load(id,{
fetch: ['Name', 'FormattedID', 'FeatureCustomField'],
callback: function(record, operation){
console.log('FeatureCustomField prior to update...', record.get('FeatureCustomField'));
record.set('FeatureCustomField', 'one');
record.save({
callback: function(record, operation) {
if(operation.wasSuccessful()) {
console.log('FeatureCustomField after update..', record.get('FeatureCustomField'));
}
}
})
}
})
}
});
}
});
我們鼓勵使用最新版本的AppSDK2,它是當前的rc2。 AppSDK2還沒有在GA中,而且它們較早的候選版本(如p5)與WS API v2.0的當前版本不兼容。與WS API的v2.0兼容的AppSDK2的第一個候選版本是rc1。我們不保證與p5的向後兼容性,並且在某些領域它們肯定不兼容。例如,在v2.0中,由於性能原因,我們刪除了在相同響應中返回子集合的功能。在v2.0中,獲取集合將返回一個對象,其中包含從中獲取收集數據的計數和url。的WS API。 在舊版本的WS API中,某些提取列表會創建大量遞歸調用,並且包含在提取中的所有集合都會使調用非常昂貴。這是使用p5時的一個考慮因素 - 隨着現有代碼的進一步發展,重寫它將與WS API v2.0和AppSDK2的更新版本保持一致。
至於你的第二個問題的答案,如果兒童故事的record.get('PortfolioItem')
也會拉起這個史詩的父親的特徵,下面是測試的細節: 假設你有一個用戶故事「故事777」有一個特徵父母,也是一個小孩「故事777」。
上的用戶故事的「故事777」這個查詢將返回一個空PortfolioItem屬性,但特徵屬性將引用史詩故事的特點父:
https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/12352608129&query=(Name = "story 777bbb")&fetch=PortfolioItem,Feature
下面是結果的一個片段。 PortfolioItem爲空:
Feature: {
_rallyAPIMajor: "2",
_rallyAPIMinor: "0",
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/portfolioitem/feature/12483739639",
_refObjectUUID: "70c2a212-ae63-4a21-ae0b-2dcbbc25206c",
_objectVersion: "66",
_refObjectName: "f1",
_type: "PortfolioItem/Feature"
},
PortfolioItem: null,
_type: "HierarchicalRequirement"
的 「史詩777」 類似的查詢:
https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/12352608129&query=(Name = "epic 777")&fetch=PortfolioItem,Feature
會同時顯示PortfolioItem和功能指向同一個對象:
Feature: {
_rallyAPIMajor: "2",
_rallyAPIMinor: "0",
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/portfolioitem/feature/12483739639",
_refObjectUUID: "70c2a212-ae63-4a21-ae0b-2dcbbc25206c",
_objectVersion: "66",
_refObjectName: "f1",
_type: "PortfolioItem/Feature"
},
PortfolioItem: {
_rallyAPIMajor: "2",
_rallyAPIMinor: "0",
_ref: "https://rally1.rallydev.com/slm/webservice/v2.0/portfolioitem/feature/12483739639",
_refObjectUUID: "70c2a212-ae63-4a21-ae0b-2dcbbc25206c",
_objectVersion: "66",
_refObjectName: "f1",
_type: "PortfolioItem/Feature"
},
如果我有一個孩子史詩的故事,這個兒童故事的record.get('PortfolioItem')是否也拉起了史詩般的父母的特徵? –
不,但是record.get('Feature')應該返回史詩的父功能。我在答案中增加了更多信息。 – nickm
感謝您的幫助。 –