2

How do you create a new object (like a defect) using SDK2?

This must be obvious and I'm just missing it-- I've been using SDK2 for a while but this has sever come up. It is something under the data part of the SDK hierarchy?

4

1 回答 1

3

您可以通过对象模型的实例来执行此操作,类似于以下内容:

Rally.data.ModelFactory.getModel({
    type: "Defect",
    success: function (defectModel) {
        var newDefect = Ext.create(defectModel, {
            Name         : "My New Defect from SDK2",
            Priority     : "Normal",
            Severity     : "Minor Problem",
            Description  : "Improper display of...",
            State        : "Submitted"
            // Other relevant/required fields
        });

        newDefect.save({
            callback: function(result, operation) {
                if(operation.wasSuccessful()) {
                   //Get the new defect's objectId
                   var objectId = result.get('ObjectID');
                }
            }
        });
    }
});

文档中的以下页面显示了 AppSDK2 的完整创建/读取/更新/删除周期:

https://developer.help.rallydev.com/apps/2.0p5/doc/#!/guide/appsdk_20_data_models

于 2013-05-03T01:09:55.120 回答