没有为新功能记录生成FormattedID [英] FormattedID is not getting generated for new feature record

查看:71
本文介绍了没有为新功能记录生成FormattedID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的代码中,我试图复制一个现有功能,并且为此创建一个新对象,因为DeepCopy功能对我不起作用.但是不会为新的功能对象生成formattedId

In the code below I am trying to copy a existing feature, and for that creating a new object as DeepCopy function is not working for me. But formattedId is not getting generated for new feature object

Rally.onReady(function() {
var newObj = {};
Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',
    autoScroll: true,
    launch: function() {
        Ext.create('Rally.ui.dialog.ChooserDialog', {
            //model: 'PortfolioItem/Feature',
            //fetch: ['FormattedID','Name','UserStories'],
            width: 450,
            autoScroll: true,
            height: 525,
            title: 'Select to Copy',
            pageSize: 100,
            closable: false,
            selectionButtonText: 'Copy',
            //autoLoad: true,                   
            artifactTypes: ['portfolioitem'],
            autoShow: true,
            listeners: {
                artifactChosen: function(selectedRecord) {
                    newObj = selectedRecord;
                    this.onqModelRetrieved();
                },
                scope: this
            },
            storeConfig : {
                filters: [
                    {
                        property: 'PortfolioItemType.Name',
                        operator: '!=',
                        value: ''
                    }
                ]
            }
        });     
    },
    onqModelRetrieved: function() {
        Rally.data.ModelFactory.getModel({
            type: 'PortfolioItem',
            success: this.onModelRetrieved,
            scope: this
        });     
    },      
    onModelRetrieved: function(model) {
        this.model = model;
        this.createFeature();
    },

    createFeature: function() {
        var record = Ext.create(this.model, {
            Name: "(Copy of) " + newObj.data.Name,
            //State: 'Open',
            Description: newObj.data.Description,
            type: newObj.data.Workspace.type
        });
        record.save;
    }               
});

Rally.launchApp('CustomApp', {
    name: 'Example'
}); 

});

请提出任何建议,对此有任何帮助.

Please any suggestion, any help on this..

推荐答案

根据WS API文档,PortfolioItem是不可创建的类型.经过一些修改,这是您创建功能的代码.以下是两个示例.

Per WS API documentation, PortfolioItem is a non-creatable type. With some modifications, here is your code that creates a feature. Below are two examples.

在第一个示例中,我在ChooserDialog的 artifactTypes 中将 portfolioitem 替换为 portfolioitem/feature .

I replaced portfolioitem with portfolioitem/feature in the artifactTypes of the ChooserDialog in the first example.

第二个示例允许选择pi类型,请注意,第二个示例中的 Rally.data.ModelFactory.getModel 中的类型是动态设置的.

The second example allows a choice of pi types, and notice that the type in Rally.data.ModelFactory.getModel in the second example is set dynamically.

示例1(仅功能):

Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',
    items:{ html:'<a href="https://help.rallydev.com/apps/2.0rc3/doc/">App SDK 2.0rc3 Docs</a>'},
    _newObj : {},
    launch: function() {
        Ext.create('Rally.ui.dialog.ChooserDialog', {
            width: 450,
            autoScroll: true,
            height: 525,
            title: 'Select to Copy',
            pageSize: 100,
            closable: false,
            selectionButtonText: 'Copy',                  
            artifactTypes: ['portfolioitem/feature'],
            autoShow: true,
            listeners: {
                artifactChosen: function(selectedRecord) {
                    console.log(selectedRecord.get('FormattedID') + ', ' + selectedRecord.get('Name') + ' was chosen');
                    this._newObj = selectedRecord;
                    this.onqModelRetrieved();
                },
                scope: this
            },
        }); 
    },
     onqModelRetrieved: function() {
        Rally.data.ModelFactory.getModel({
            type: 'PortfolioItem/Feature',
            success: this.onModelRetrieved,
            scope: this
        });     
    },      
    onModelRetrieved: function(model) {
        this.model = model;
        this.createFeature();
    },

    createFeature: function() {
        var record = Ext.create(this.model, {
            Name: "(Copy of) " + this._newObj.get('Name'),
        });
        record.save({
            callback: function(result, operation) {
                if(operation.wasSuccessful()) {
                    console.log('created feature:', result.get('ObjectID'),result.get('FormattedID'),result.get('Name'));
                }
                else{
                    console.log("error");
                }
            }
        });
    }       
});

示例2(所有pi类型):

EXAMPLE 2 (all pi types):

第二个示例适用于所有pi类型,并且将 artifactTypes 扩展为包括主题,主动性和功能:

The second example works with all pi types, and artifactTypes is expanded to include themes, initiative and features:

artifactTypes: ['portfolioitem/theme','portfolioitem/initiative','portfolioitem/feature']

这是代码:

Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',
    items:{ html:'<a href="https://help.rallydev.com/apps/2.0rc3/doc/">App SDK 2.0rc3 Docs</a>'},
    _newObj : {},
    _type : null,
    launch: function() {
        Ext.create('Rally.ui.dialog.ChooserDialog', {
            width: 450,
            autoScroll: true,
            height: 525,
            title: 'Select to Copy',
            pageSize: 100,
            closable: false,
            selectionButtonText: 'Copy',                  
            artifactTypes: ['portfolioitem/theme','portfolioitem/initiative','portfolioitem/feature'],
            autoShow: true,
            storeConfig:{
                fetch: ['Name','PortfolioItemTypeName']
            },
            listeners: {
                artifactChosen: function(selectedRecord) {
                    console.log(selectedRecord.get('FormattedID') + ', ' + selectedRecord.get('Name') + ' of type ' + selectedRecord.get('PortfolioItemTypeName') + ' was chosen');
                    this._type = selectedRecord.get('PortfolioItemTypeName');
                    this._newObj = selectedRecord;
                    this.onqModelRetrieved();
                },
                scope: this
            },
        }); 
    },
     onqModelRetrieved: function() {
        var that = this;
        that._type = 'PortfolioItem/' + that._type,
        Rally.data.ModelFactory.getModel({
            type: that._type,
            success: this.onModelRetrieved,
            scope: this
        });     
    },      
    onModelRetrieved: function(model) {
        this.model = model;
        this.createFeature();
    },

    createFeature: function() {
        var record = Ext.create(this.model, {
            Name: "(Copy of) " + this._newObj.get('Name'),
        });
        record.save({
            callback: function(result, operation) {
                if(operation.wasSuccessful()) {
                    console.log('created feature:', result.get('ObjectID'),result.get('FormattedID'),result.get('Name'),result.get('PortfolioItemTypeName'));
                }
                else{
                    console.log("error");
                }
            }
        });
    }       
});

这篇关于没有为新功能记录生成FormattedID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆