Change parent state from child issue

Hi,

I'm trying to use the javascript workflow and I have to say it's not so easy.

Right now I need to do a pretty simple thing : when a subtask with Type "task" comes to State "in progress", parent task, if it has Type "user story", must come to State "in progress" too. Simple.

I wrote this :

```

exports.rule = entities.Issue.onChange({
// TODO: give the rule a human-readable title
title: 'In-progress-task-to-story',
guard: function(ctx) {
// TODO specify the conditions for executing the rule
return true;
},
action: function(ctx) {
// TODO: specify what to do when a change is applied to an issue
var issue = ctx.issue;
if (issue.fields.becomes(ctx.State, ctx.State['In Progress'])) {
var parent = issue.links['subtask of'].first();
if (parent.type == 'user story' && parent.fields.State != 'in progress') {
parent.fields.State = 'in progress';
}
}
},
requirements: {
// TODO: add requirements

}
});

```

Based on what I found in the doc, but for example `ctx.State`is undefined.
I couldn't find any detailed reference doc, just a few examples and tutorials.
Thanks for your help.

Regards

Laurent

1 comment
Comment actions Permalink
Official comment

Hello,

Would you please add all used fields (Type and State) to the requirements section? Please refer to the Default Workflows and JavaScript Workflow Quick Start Guide articles for more information about workflows. Should you have any further questions, feel free to contact us. 

Please sign in to leave a comment.