create/update user story using rally app sdk

Rohan Dalvi

Until now, I have been querying the data stores using Rally App SDK, however, this time I have to update a story using the js sdk. I tried looking up for examples for some sample code that demonstrates how the App SDK can be used to update/add values in Rally. I have been doing CRUD operations using Ruby Rally API but never really did it with the app sdk.

Can anyone provide some sample code or any link to where I could check it out?

Thanks

nickm

See this help document on updating and creating reocrds. Below are examples - one updates a story, the other creates a story. There is not much going on in terms of UI: please enable DevTools console to see console.log output.

Here is an example of updating a Defect Collection on a User Story:

Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',

    launch: function() {
        console.log("launch");
       Rally.data.ModelFactory.getModel({
            type: 'User Story',
            success: this._onModelRetrieved,
            scope: this
        });
    },
    _onModelRetrieved: function(model) {
        console.log("_onModelRetrieved");
        this.model = model;
        this._readRecord(model);
    },

     _readRecord: function(model) {
        var id = 13888228557;
        console.log("_readRecord");
        this.model.load(id, {
            fetch: ['Name', 'Defects'],
            callback: this._onRecordRead,
            scope: this
        });
    },

    _onRecordRead: function(record, operation) {
        console.log('name...', record.get('Name'));
        console.log('defects...', record.get('Defects'));
        if(operation.wasSuccessful()) {
            //load store first by passing additional config to getCollection method
             var defectStore = record.getCollection('Defects', {
                autoLoad: true,
                listeners: { load: function() {
                    //once loaded now do the add and sync
                    defectStore.add({'_ref':'/defect/13303315495'});
                    defectStore.sync({
                        callback: function() {
                            console.log('success');
                        }
                    });
                }}
            });
        }

    }, 
});

Here is an example of creating a user story, setting a project and scheduling for an iteration:

Ext.define('CustomApp', {
    extend: 'Rally.app.TimeboxScopedApp',
    componentCls: 'app',
    scopeType: 'iteration',
    comboboxConfig: {
        fieldLabel: 'Select an Iteration:',
        labelWidth: 100,
        width: 300
    },

    addContent: function() {   
        this._getIteration();
    },

    onScopeChange: function() {
        this._getIteration();
    },


    _getIteration: function() {
            var iteration = this.getContext().getTimeboxScope().record.get('_ref');
            console.log('iteration',iteration);

            if (!this.down('#b2')) {
                 var that = this;
                 var cb = Ext.create('Ext.Container', {

                items: [
                    {
                        xtype  : 'rallybutton',
                        text      : 'create',
                        id: 'b2',
                        handler: function() {
                            that._getModel(iteration); 
                        }
                    }

                    ]
                });
            this.add(cb);
            }
        },


    _getModel: function(iteration){
            var that = this;
            Rally.data.ModelFactory.getModel({
                type: 'UserStory',
                context: {
                    workspace: '/workspace/12352608129'
                },
                success: function(model) {  //success on model retrieved
                    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._readAndUpdate(iteration);
                            }
                            else{
                                console.log("?");
                            }
                        }
                    });
                }
            });
        },

        _readAndUpdate:function(iteration){
            var id = this._record.get('ObjectID');
            console.log('OID', id);
            this._model.load(id,{
                fetch: ['Name', 'FormattedID', 'ScheduleState', 'Iteration'],
                callback: function(record, operation){
                    console.log('ScheduleState prior to update:', record.get('ScheduleState'));
                    console.log('Iteration prior to update:', record.get('Iteration'));
                    record.set('ScheduleState','In-Progress');
                    record.set('Iteration', iteration);
                    record.set('Project', '/project/12352608219')
                    record.save({
                        callback: function(record, operation) {
                            if(operation.wasSuccessful()) {
                                console.log('ScheduleState after update..', record.get('ScheduleState'));
                                console.log('Iteration after update..', record.get('Iteration'));
                            }
                            else{
                                console.log("?");
                            }
                        }
                    });
                }
            })
        }
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

create/update user story using rally app sdk

From Dev

Updating iteration for story using Rally SDK

From Dev

Can I create a task for a user story with Rally SDK?

From Dev

Rally - Create User Story with tags using REST (non-API)

From Dev

Rally sdk - get list of tasks from a story object

From Dev

Rally-app-builder displays nothing in browser for "Story Board" app

From Dev

Rally-app-builder displays nothing in browser for "Story Board" app

From Dev

Unable to update user story in Rally via Java API

From Dev

Rally C#: Is it possible to create a new user story along with an attachment? (Avoiding to query for the user-story reference)

From Dev

How to specify project when creating a story using Rally Java toolkit?

From Dev

How to specify project when creating a story using Rally Java toolkit?

From Dev

Upgrading my Rally app from rally SDK 1.32 to rally SDK 2.0p5

From Dev

Rally App SDK 2.0 - filter by date

From Dev

User login flow for Android app of RALLY

From Dev

Fetch user stories by iteration using Rally API

From Dev

Fetch user stories by iteration using Rally API

From Dev

Rally app SDK 2.0rc1 - Uncaught ReferenceError: rally is not defined

From Dev

Update Custom user attribute using Rally User Management

From Dev

How to get user story bythe given task in SDK2.0

From Dev

How to get user story bythe given task in SDK2.0

From Dev

How to get the current user's role in a custom rally app in production?

From Dev

Getting user app token using react-native facebook SDK

From Dev

Can I masquerade as another user when creating/updating Rally artifact using Rally WSAPI?

From Dev

Rally: How to Map test cases with user stories using REST API?

From Dev

Sharing Image with Text Story on Facebook Using Facebook SDK 4.1

From Dev

Rally - clone existing app

From Dev

Rally - clone existing app

From Dev

Publishing Facebook custom story using API calls from IOS app

From Dev

Rally SDK 2 custom sorters

Related Related

  1. 1

    create/update user story using rally app sdk

  2. 2

    Updating iteration for story using Rally SDK

  3. 3

    Can I create a task for a user story with Rally SDK?

  4. 4

    Rally - Create User Story with tags using REST (non-API)

  5. 5

    Rally sdk - get list of tasks from a story object

  6. 6

    Rally-app-builder displays nothing in browser for "Story Board" app

  7. 7

    Rally-app-builder displays nothing in browser for "Story Board" app

  8. 8

    Unable to update user story in Rally via Java API

  9. 9

    Rally C#: Is it possible to create a new user story along with an attachment? (Avoiding to query for the user-story reference)

  10. 10

    How to specify project when creating a story using Rally Java toolkit?

  11. 11

    How to specify project when creating a story using Rally Java toolkit?

  12. 12

    Upgrading my Rally app from rally SDK 1.32 to rally SDK 2.0p5

  13. 13

    Rally App SDK 2.0 - filter by date

  14. 14

    User login flow for Android app of RALLY

  15. 15

    Fetch user stories by iteration using Rally API

  16. 16

    Fetch user stories by iteration using Rally API

  17. 17

    Rally app SDK 2.0rc1 - Uncaught ReferenceError: rally is not defined

  18. 18

    Update Custom user attribute using Rally User Management

  19. 19

    How to get user story bythe given task in SDK2.0

  20. 20

    How to get user story bythe given task in SDK2.0

  21. 21

    How to get the current user's role in a custom rally app in production?

  22. 22

    Getting user app token using react-native facebook SDK

  23. 23

    Can I masquerade as another user when creating/updating Rally artifact using Rally WSAPI?

  24. 24

    Rally: How to Map test cases with user stories using REST API?

  25. 25

    Sharing Image with Text Story on Facebook Using Facebook SDK 4.1

  26. 26

    Rally - clone existing app

  27. 27

    Rally - clone existing app

  28. 28

    Publishing Facebook custom story using API calls from IOS app

  29. 29

    Rally SDK 2 custom sorters

HotTag

Archive