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

Update other or parent issue content when child issue update #205

Closed luk3k0 closed 3 years ago

luk3k0 commented 3 years ago

Can i update other issue or parent issue when sub issue change?

I have 2 project with:

When issue in private project update status then issue in public project have to change status, content too.

Here is the before save code:

@need_create = status_id_changed? && !new_record?

Incomplete after save code:

if @need_create

  # change if status is open in private tracker
  if @issue.status_id==3 && @issue.tracker_id==2
    issue = Issue.find(@issue.parent_id)
    issue.status_id = 3
    issue.description = @issue.description
    issue.save
  end

  # change if status is done in private tracker
  if @issue.status_id==8 && @issue.tracker_id==2
    issue = Issue.find(@issue.parent_id)
    issue.status_id = 8
    issue.description = @issue.description
    issue.save
  end

end

It's not working. I know something not right with after save, but i don't know how to fix it. I would be very grateful if you could help.

Thank you.

luk3k0 commented 3 years ago

Oh, i found it The after save code should be like this:

if @need_create

  # change if status is open in private tracker
  if @issue.status_id==3 && @issue.tracker_id==2
    root.update(
    :status_id=>3,
    :description = description
  end

  # change if status is done in private tracker
  if @issue.status_id==8 && @issue.tracker_id==2
    root.update(
    :status_id=>8,
    :description = description
  end

end