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

Automatic assignment of status "Immediate" in a specific tracker #277

Closed mandor3 closed 2 years ago

mandor3 commented 2 years ago

Hello, I am a ruby noob, I used this plugin in search of a solution for the flexibility of a new tracker. I want all tasks of the new tracker to be automatically assigned the status immediate when created, but the default status remains normal. I wrote this code and I don't understand why it doesn't work: if @issue.new_record? if(@issue.tracker_id == '16') @issue.priority_id = '5' end end

AirTibu commented 2 years ago

Hi,

What is your exact intention? To change the status or change the priority? Because you wrote about status, but in your code you try to change the priority.

Note: You should use your code in BEFORE SAVE section

mandor3 commented 2 years ago

Hi again, Yes, I'm talking about priority. Tell me, please, what could be the problem?

AirTibu commented 2 years ago

Hi,

Try this code in BEFORE SAVE section:


@issue.priority_id=(5) if new_record? && tracker_id == '16'

I hope it helps!

mandor3 commented 2 years ago

Wow, it works. Thank you. Can I ask a couple more questions without creating a new topic also related to this new tracker?

AirTibu commented 2 years ago

I’m glad to hear that!

Yes, you can ask, I try to help, if I can.

mandor3 commented 2 years ago

Good morning! I use the custom Datetime field from this plugin in the "Incidents" tracker https://www.redmine.org/plugins/redmine_datetime_custom_field Can custom workflow work with this? If yes, then in this case, tell me how to implement it so that it refers to the "Completion date" field and, until it is filled, does not give the opportunity to close or cancel the task?

AirTibu commented 2 years ago

Hi,

The datetime customfield is working same as other customfields. To avoid closing with missing datetime, use this code in BEFORE SAVE section:


if (closing? || closed?) && !custom_field_value(1).present?
    errors.add(:base,"The Completion date field shall be filled before closing!")
    return true
end

Change the custom field id in code! The number "1" shall be changed:

!custom_field_value(1).present?

I hope it helps!

mandor3 commented 2 years ago

Thank you, everything works fine, sorry for the long absence - a lot of work