Rally Software

Expand all | Collapse all

Rally app SDK 2 - Create or update a story and set its feature

  • 1.  Rally app SDK 2 - Create or update a story and set its feature

    Posted 03-10-2019 09:23 AM

    Hello,

     

    I can't manage to attach a story to a feature thanks to the Rally app SDK 2.1.

     

    Using a CUSTOM HTML block, I can create a new story thanks to this code:

    // Create a new story
    function addStory() {

    console.log('Creating a new story...');
    // Retrieve the Rally user stories model
    Rally.data.ModelFactory.getModel({
    type: 'UserStory',
    context: {
    workspace: '/workspace/12345',
    project: '/project/12345'
    },
    success: function(model) {
    // Create a new story thanks to the retrieved model
    var story = Ext.create(model, {
    Name: 'Can be deleted, created via Rally app SDK 2.1',
    Description: 'Dummy generated story - tests',
    });
    // Save the new story
    story.save({
    callback: function(result, operation) {
    if(operation.wasSuccessful()) {
    console.log('New story created!', result.get('FormattedID'));
    }
    }
    });
    }
    });
    }

    But the application hangs and the story is not being created if I try to add the parent feature:

    // Create a new story
    function addStory() {

    console.log('Creating a new story...');
    // Retrieve the Rally user stories model
    Rally.data.ModelFactory.getModel({
    type: 'UserStory',
    context: {
    workspace: '/workspace/12345',
    project: '/project/12345'
    },
    success: function(model) {
    // Create a new story thanks to the retrieved model
    var story = Ext.create(model, {
    Name: 'Can be deleted, created via Rally app SDK 2.1',
    Description: 'Dummy generated story - tests',
    PortfolioItem: '/portfolioitem/featureset/12345'
    });
    // Save the new story
    story.save({
    callback: function(result, operation) {
    if(operation.wasSuccessful()) {
    console.log('New story created!', result.get('FormattedID'));
    }
    }
    });
    }
    });
    }

    Here is the full application code:

    <!DOCTYPE html>
    <html>
    <head>
    <title>test - Story creation</title>

    <script type="text/javascript" src="/apps/2.1/sdk.js"></script>

    <script type="text/javascript">

    // SDK documentation: https://docs.ca.com/en-us/ca-agile-central/saas/apps/2.1/doc/#!/api

    Rally.onReady(function() {

    // Create a new story
    function addStory() {

    console.log('Creating a new story...');
    // Retrieve the Rally user stories model
    Rally.data.ModelFactory.getModel({
    type: 'UserStory',
    context: {
    workspace: '/workspace/12345',
    project: '/project/12345'
    },
    success: function(model) {
    // Create a new story thanks to the retrieved model
    var story = Ext.create(model, {
    Name: 'Can be deleted, created via Rally app SDK 2.1',
    Description: 'Dummy generated story - tests',
    PortfolioItem: '/portfolioitem/featureset/12345'
    });
    // Save the new story
    story.save({
    callback: function(result, operation) {
    if(operation.wasSuccessful()) {
    console.log('New story created!', result.get('FormattedID'));
    }
    }
    });
    }
    });
    }

    // The Rally application
    Ext.define('Rally.grg.storyCreation', {
    extend: 'Rally.app.App',

    // Method fired on application launch
    // Retrieve release features asynchronously
    launch: function() {
    console.log('Launch...');
    addStory();
    }
    });

    Rally.launchApp('Rally.grg.storyCreation', {
    name: 'test - Story creation'
    });

    });
    </script>

    <style type="text/css">

    </style>
    </head>
    <body></body>
    </html>

    Would you have an idea?

    Thanks



  • 2.  Re: Rally app SDK 2 - Create or update a story and set its feature

    Posted 03-11-2019 09:38 AM

    In fact, it works well. 

    It failed for a specific feature, but works for other features... 



  • 3.  Re: Rally app SDK 2 - Create or update a story and set its feature

    Posted 03-11-2019 09:50 AM

    Hi.

     

    So, it sounds like it's working well for all features, but one feature that isn't working. What error are you getting with this one feature? 

     

    Did you try associating that story to that same feature from the user interface or from WSAPI?

     

    Thanks,

    Sagi



  • 4.  Re: Rally app SDK 2 - Create or update a story and set its feature

    Posted 03-11-2019 12:02 PM

    Hi,  Can you associate the story to the feature through the UI?  If you can test it, that may give you a clue why this one story to feature association may be failing.

     

    -Edwin