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

Accessing relations to an issue #296

Closed vomus closed 1 year ago

vomus commented 1 year ago

Hi! I am trying to change a status to issues that follow an issue which gets closed. I fiddled around with some code from the console but the way it worked in there does not seem to apply to custom_workflow.

if Group.find(95).users.include? User.current
    if @issue.closed? && (@issue.relations.length > 0)
        for j in 0..@issue.relations.length-1
            self.relations[j]["issue_to_id"]["status_id"] = 2
        end
    end
end

The log says that "undefined method `[]=' for the Integer". Can anyone help in this? I am not much of a Ruby expert here. :-)

vomus commented 1 year ago

This one seems to work...

if Group.find(95).users.include? User.current
    if @issue.closed? && (@issue.relations.length > 0)
        for j in 0..@issue.relations.length-1
            q = Issue.find(@issue.relations[j]["issue_to_id"])
            q["status_id"] = 2
            q.save!
        end
    end
end