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

Auto assign random project member #163

Closed smlabonia closed 2 years ago

smlabonia commented 4 years ago

I want to auto assign to users with a specific role on the project.

I tried with this code without success.

if new_record? arr = Array.new arr = User.find{(self.project_id) && (role==2)}.first

count = arr.count random_offset = rand(count) random_user = arr.offset(random_offset).first

@issue.assigned_to == random_user end

Could you help me please?

picman commented 4 years ago

You fetch members incorrectly, I think. Try this:

#arr = User.find{(self.project_id) && (role==2)}.first
members = project.users_by_role
role = Role.find_by(id: 2)
arr = members[role]