anteo / redmine_custom_workflows

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

How to send a mail notification of an issue to members of certain role if the status is changed to a specific value #305

Closed SinghNanak closed 1 year ago

SinghNanak commented 1 year ago

@picman can you help plz. i want to send email to role(project manager) when a issues status is changed to hold. can you create a workflow for that.

picman commented 1 year ago

E.g.: It sends an email to all project's members with the role 3 if the status is changed to 6.

Before save

@status_changed = status_id_changed? && !new_record?

After save

if @status_changed && (self.status_id == 6) # Rejected
  recipients = []; 
  self.project.members.each do |member|
   if member.member_roles.collect(&:role_id).include?(3) # Manager
     recipients << member.user
   end
  end
  subject = 'Issue status changed'
  body = "The status of ##{self.id} has been changed to Rejected"
  recipients.each do |recipient|
    CustomWorkflowMailer.deliver_custom_email(recipient, 
      subject, body)
  end
end
SinghNanak commented 1 year ago

Thank you, I appreciate your help