2013-05-03 76 views
2

如何使用SDK2创建新对象(如缺陷)?在SDK2中创建对象

这一定很明显,我只是想念它 - 我一直在使用SDK2一段时间,但这已经出现了。它在SDK层次结构的数据部分下面?

回答

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