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 can I copy or create tags from custom fields values? #272

Closed cbmarchetti closed 2 years ago

cbmarchetti commented 2 years ago

@cf_key_value = CustomFieldEnumeration.where(:id=> custom_field_value(1).to_s,:custom_field_id => '1').first.to_s

if @issue.tracker_id == 4 if custom_field_value(1) != custom_value_for(1).try(&:value) self.tag_list.add(@cf_key_value) self.save end end

AirTibu commented 2 years ago

Hi,

Use this code in BEFORE SAVE section:


if (custom_field_value(1) != custom_value_for(1).try(&:value)) && tracker_id == 4
    self.save_custom_field_values
    self.tag_list.add(CustomFieldEnumeration.where(:id=> custom_field_value(1).to_s,:custom_field_id => '1').first.to_s)
end

I hope it helps!

cbmarchetti commented 2 years ago

Hi, thanks for your help, but it's not working yet tags.zip

AirTibu commented 2 years ago

Hi,

This code was tested and works properly. Do you use any special plugin for tags?

cbmarchetti commented 2 years ago

redmineup_tags 2.0.11 https://www.redmineup.com/pages/plugins/tags/

image

AirTibu commented 2 years ago

Hi,

Try it with @issue instead of self:


if (custom_field_value(1) != custom_value_for(1).try(&:value)) && tracker_id == 4
    @issue.save_custom_field_values
    @issue.tag_list.add(CustomFieldEnumeration.where(:id=> custom_field_value(1).to_s,:custom_field_id => '1').first.to_s)
end
cbmarchetti commented 2 years ago

Thank you very much! @AirTibu