V
V
vinznsk2017-10-18 17:21:53
ruby
vinznsk, 2017-10-18 17:21:53

How to link tasks in Ruby (Redmine)?

Good afternoon!
The problem is this:
I am trying to build a workflow for Redmine using plugin https://github.com/anteo/redmine_custom_workflows
FAQ: https://github.com/anteo/redmine_custom_workflows/...
Examples: https://github.com /anteo/redmine_custom_workflows/...
My task is to create a related task (relation_type => 'relates') when a task is moved to a certain status (let it be status "9").
The plugin above has several fields:
Script to execute before saving the observable

@need_create = status_id_changed? && status_id==9 && !new_record? // Идет проверка на изменение статуса в 9

Script to execute after saving the observable
if @need_create
  issue = Issue.new(
    :author => User.current,
    :project => project,
    :tracker_id => 7,
    :assigned_to => Group.find(17),
    :subject => self.subject,
    :description => self.description
    )
  issue.save!
end

This script creates a new issue in another tracker.
The problem is linking the new task to the old one. Within the framework of this script, this cannot be done, I tried the code:
:issue_to => id,
    :relation_type => 'relates'

I admit that the connection fails, since the connection occurs after the task is saved, and the creation script is entered before. If so, then there are 2 options:
Option 1: Perhaps it makes sense to create a new script that will track the appearance of a new task, check for the existence of tasks with the same name and link them together.
Option 2: copy the task from the current one, then change the "copied" link to "related" and copy the "subject" field from the old one (to remove "Copy ....").
But how to do this I have no idea.
PS Not a programmer, I just needed to make a workflow.
Can someone help write a script (for a fee).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question