anteo / redmine_custom_workflows

Allows to create custom workflows for Redmine
http://www.redmine.org/plugins/custom-workflows
GNU General Public License v2.0
182 stars 72 forks source link

I am trying to build a workflow which will prevent the closing of a task #299

Closed gaurav-cointab closed 1 year ago

gaurav-cointab commented 1 year ago

Hi Team,

I am trying to build a workflow where I am trying to make "notes", as mandatory for certain type of project, for a certain tracker, for a certain status. So this will go into the before save issue flow.

In that I need to check if the user is marking a certain tracker in a certain project (with a custom field having a certain value) to have notes as mandatory. So I can achieve this by adding the below mentioned sudo logic in the before save.

First check for the tracker_id to be equal to certain id. Then check for the custom field of the project to be equal to a certain value. Then check for the status_id to be equal to a certain value. The check if the notes fields is blank, then raise error, otherwise allow it to run smoothly.

These steps are correct? If yes, then it would be helpful to help me write this. A certain code with placeholders would be very much appreciated.

gaurav-cointab commented 1 year ago

I am trying to use this in before save.

if (@issue.tracker_id == 22 or @issue.tracker_id == 23) and (@issue.status_id == 3 or @issue.status_id == 5 or @issue.status_id == 6) and !@issue.notes.nil? raise WorkflowError, 'Since you are closing this task, the notes are mandatory' end

It is possible that I am trying to access the notes field in the wrong way, or the condition for it is wrong. I want to raise the error only if the notes field is blank, not set. How to achieve this?

gaurav-cointab commented 1 year ago

I have also tried to change @issue.notes, @journal.notes and @current_journal.notes. Still not working.

gaurav-cointab commented 1 year ago

Found the solution in this:

https://github.com/anteo/redmine_custom_workflows/issues/57