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

New Error in Log Based on Email Code #311

Closed bhetsko closed 1 year ago

bhetsko commented 1 year ago

For some reason I now get an error with this workflow element (Reference Issue #216).

== Custom workflow exception: undefined method 'uniq' for "117":String in the production.log

The @notify_users... code provided in issue #216 worked fine for a while so I'm not sure what may have changed. I posted this question originally in that thread but it was closed, so I don't think anyone was monitoring it.

Appreciate any help.

_Originally posted by @bhetsko in https://github.com/anteo/redmine_custom_workflows/issues/216#issuecomment-1460862188_

image

AirTibu commented 1 year ago

Check the type of customfield 117. It should be multivalues user type.

bhetsko commented 1 year ago

Thank you!! I don't even remember changing it from multivalue. Is there a Before Save code that will support the single value option? For now, I will keep as multivalue. Thanks again.

AirTibu commented 1 year ago

Hi,

You should manage both types with below code. First you should test the CustomField, that it has multivalues or not:


if CustomField.find(CF_ID).multiple?
@notify_users = Issue.find(@issue.id).custom_field_value(CF_ID).uniq.sort != @issue.custom_field_value(CF_ID).uniq.sort if @issue.id
else
@notify_users = Issue.find(@issue.id).custom_field_value(CF_ID) != @issue.custom_value_for(CF_ID).try(&:value) if @issue.id
end

Note: Do not forget to change the CF_ID.

I hope it helps!