所以我试图同步功能的自定义字段与其子故事的(史诗的)自定义字段值。拉力赛:从史诗故事的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
感谢您的帮助。 –