JavaScript workflow error set state

Hello guys,

 

I'm trying to achieve the following behavior:

 

I've got a agile board for conceptionate issues. If the issue gets moved into a column (which is identified by the issuestate), it should disapear from this board and should pop up in the next boards first column.

 

For this I want to create a custom javascript workflow which triggers on issue change. At this point the issues state should be changed again.

 

I've got this snippet:

 

var entities = require('@jetbrains/youtrack-scripting-api/entities');

exports.rule = entities.Issue.onChange({
  // TODO: give the rule a human-readable title
  title: 'Concept-is-done',
  guard: function(ctx) {   
    return ctx.issue.fields.State.name == ctx.State.ConceptDone.name;
  },
  action: function(ctx) {
    var issue = ctx.issue;
    issue.fields.State = ctx.State.ReadyForImplementation;
  },
  requirements: {
    State: {
      type: entities.State.fieldType,
      ConceptDone: {
        name: "Konzeptionierung abgeschlossen"
      },
      ReadyForImplementation: {
          name: "Bereit zur Umsetzung"
      }
    }
  }
});

 

Sadly, if i try to move the issue in the column "ConceptDone" I get an workflow runtime error with the following error: "Cannot set value to custom field State".

 

I woudl be happy if someone has an idea.

 

Best regards

0
5 comments
Avatar
Permanently deleted user

Hi,
Do you have any State Machine rules attached to your project? If there is a rule that doesn't contain a transition from 'ReadyForImplementation' to 'ConceptDone', then your code will fail with such an error.

0
Avatar
Permanently deleted user

Hello Mariya,

at least I did not build a State Machine rule by myself.

Is there a way to figure out if there is one active by default without check every rule by hand?

 

Best regards

 

0
Avatar
Permanently deleted user

Yes, it is easy to see on issue screen: if you have a circle-like icon near the value of the State field, then you have a state-machine attached.

I would like to see your logs to give more accurate assumptions. Do you have InCloud or Standalone installation?

0
Avatar
Permanently deleted user

I don't see a circle-like icon there.

 

Sadly we have a Standalone installation which is just reachable over intranet.

 

You can find the full stacktrace here: https://pastebin.com/rEK4An0A

0
Avatar
Permanently deleted user

I just made it working. I renamed the ReadyForImplementation State and replaced the spaces in its german name. Without spaces it seems to be working.

0

Please sign in to leave a comment.