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

Taking information from the subtask to the parent #244

Closed ashrafalzyoud closed 2 years ago

ashrafalzyoud commented 2 years ago

how i can take cfs[1] from subtask to parent?>

AirTibu commented 2 years ago

Hi,

An issue can have more than one subtask, therefore you should identify more clearly, that what is your intention.

You can summarise the custom fields, if it has number type. If it contains text, then you should make a decision, which subtask data is needed (first or last subtask, or you can concat the strings)

I hope it helps!

ashrafalzyoud commented 2 years ago

task have one subtask custom field maybe text or integer

AirTibu commented 2 years ago

Hi,

Try this code:


if self == root && root.children? 
    subtask_cf_value = root.children.first.custom_field_value(1).to_s
end

I hope it helps!

ashrafalzyoud commented 2 years ago

@picman @AirTibu its not working this code

ashrafalzyoud commented 2 years ago
if self == root && root.children? 
@issue.custom_field_values = { '1' => self.root.children.first.custom_field_value(1).to_f }
end

im try this code its work for me but i dont know its good or no

AirTibu commented 2 years ago

What is the field type? Float?

ashrafalzyoud commented 2 years ago

its depend with type cfs

AirTibu commented 2 years ago

Try this:


if @issue != @issue.root && @issue.root.children? 
@issue.custom_field_values = { '1' => @issue.root.children.first.custom_field_value(1).to_s.to_f}
end
ashrafalzyoud commented 2 years ago

error Workflow script executable before saving observable object contains error: undefined methodchildren?' for nil:NilClass `

AirTibu commented 2 years ago

One of the problem, what I mentioned above: first or last sub task data is needed?

ashrafalzyoud commented 2 years ago

first subtask

ashrafalzyoud commented 2 years ago

the problem in if @issue != @issue.root && @issue.root.children?

AirTibu commented 2 years ago

In case of string:


if @issue == @issue.root && @issue.children? 
@issue.custom_field_values = { '1' => @issue.children.first.custom_field_value(1).to_s}
end