Remove Assignee on State change
We want cards in the Backlog (Stage) to be blanked out (null), so I'm trying to create a workflow that does that when a card is moved from another stage like "Ready for Dev".
Here is the code for the workflow and it doesn't work. Any help would be great. I'm new to YouTrack workflows.
```
/**
* This is a template for an on-change rule. This rule defines what
* happens when a change is applied to an issue.
*
* For details, read the Quick Start Guide:
* https://www.jetbrains.com/help/youtrack/incloud/2019.2/Quick-Start-Guide-Workflows-JS.html
*/
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
var entities = require('@jetbrains/youtrack-scripting-api/entities');
exports.rule = entities.Issue.onChange({
// TODO: give the rule a human-readable title
title: 'When card is moved to Backlog or Being worked, remove assignee',
guard: function(ctx) {
ctx.issue.fields.becomes(ctx.Stage, ctx.Stage.Backlog);
},
action: function(ctx) {
ctx.Assignee = null;
},
requirements: {
Stage: {
type: entities.State.fieldType,
Backlog: {
name: "Backlog"
}
},
Assignee: {
type: entities.User.fieldType
}
}
});
```
Please sign in to leave a comment.
Hello,
Thank you for reaching out. Do you see any errors? Is the Assignee field single-value in your project? Are there are error badges near the rule name on the Settings -> Workflows page?
No, I have added screen shot to confirm. The Assignee is a single value.

Hello,
Thank you for the clarification. Would you please try to use the following code instead:
Should you have any further questions, feel free to contact us.
The goal here is when a card stage (state) is set to Backlog, that the assignee field is set to unassigned. I have added the "ctx.issue.fields.Assignee = null;" and the assignee field is not set to null. What I'm I missing.
Here is the field definition for the card.
Hello,
Would you please add the console.log('test'); output to your action and check the result in the workflow editor console to make sure that your action is raised?
Feel free to submit a support request to answer this question and provide additional details if you consider any data to be sensitive.
Hello Oleg,
It appears that the script is not executing. Here is the console output on Chrome after I change the stage to Backlog.

Please accept my apologies for my insufficiently clear comment. I meant the workflow editor console:
Here is the workflow editor console.
Thanks!
Would you please expand the console to check its result after performing all required actions in the required issue?
Your cooperation is greatly appreciated.
Sorry, I don't know how to run the workflow from the workflow editor, assuming that is required. I did open the console and it was empty.
Thank you for the clarification. Now, it is necessary to check why the action is not called. You can debug it by yourself. For this, add the console output to the guard section to make sure that the rule is called at all. Then, you can also check any required variables with the console.
I hope it will be helpful.
Thank you for your results!
Sorry, I did not notice that you do not use return in the guard section. Would you please try to use the following code instead:
WORKED!!!!! You are a rock star. Thank you!!!! This is closed
You are always welcome! I am happy to hear that my assistance was helpful. Should you have any further questions, feel free to contact us at any time.
Have a great day!