AnsweredAssumed Answered

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

Question asked by gregory.garcia on Mar 10, 2019
Latest reply on Mar 11, 2019 by araed02

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

Outcomes