Easiest way to keep an issue read-only in a certain state
Hi all,
I need a way to prevent modifications of all/some fields of an issue after it enters certain state(s) (f.i., if an issue is marked as Verified there is no need to allow modifications of most of its fields).
I guess, I will have to write a custom state workflow to support this behavior... and this looks like a complicated task for me.
Has anyone already implemented the same/similar functionality this or other way?
I would also expect to have the ability to mark certain states of an issue as terminal/final, thus letting YouTrack know that the issue should be treated as read-only after it enters such states... but I'm not sure whether this suggestion matches YouTrack ideology.
Regards, Anton
Please sign in to leave a comment.
Hi Anton,
Yes, you can write a workflow to prevent further changing of state Verified.
Moreover, it's possible to implement it by 2 different ways - by stateless rule (fast and granulated but not specific) and by state machine (usually used with 'State' field)
Stateless rule:
States machine:
statemachine states machine for field State {
initial state Submitted {
on open[always] do {<define statements>} transit to Open
on verify[always] do {<define statements>} transit to Verified
...
}
state Verified {
}
state Open {
on verify[always] do {<define statements>} transit to Verified
}
}
Workflow Guide should help you write and upload workflow.
Also I attached these workflow (final-state.zip). You can simply import it to your Youtrack instance at project > workflow tab.
As for marking states to be final - there is no such possibility in Youtrack, but you can control all states behavior in States Machine (2nd rule).
Attachment(s):
final-state.zip
Hi Dmitry,
thanks for the explanations!
The proposed solution looks simple...
I wonder how complex it would look if I needed to make all fields (Project, Type, State, Fix versions, etc.) of an issue readonly once it had transited to Verified state?
Should I also follow the same approach in this case? I guess, the workflow will become even more sophisticated...
Regards,
Anton
rule restrict change fields when Type.changed || Priority.changed || Fix versions.changed || project.changed { assert State.oldValue != {Verified}: "Cannot change state: 'Verified' is the final state."; }On attempt to change any of these fields message will appear.
when Type.changed || Priority.changed || Fix versions.changed || project.changed { assert State != {Verified}: "Cannot change state: 'Verified' is the final state."; }I hope the users won't be getting confused often after this rule becomes effective :)