annikoff / redmine_plugin_computed_custom_field

Computed Custom Field for Redmine
https://www.redmine.org/plugins/computed_custom_field
MIT License
81 stars 52 forks source link

Formula undefined method 'first' for nil:NilClass when setting computed formula. #128

Closed yingsheng658 closed 6 years ago

yingsheng658 commented 7 years ago

Hi annikoff,

I got the error message as Formula undefined method 'first' for nil:NilClass when setting computed formula,need your kindly support to confirm this issue. 1.Environment:Ubuntu 16.04 TLS. 2.Redmine version:Bitnami Redmine Stack v3.4.3-1. The screen shot of fail log as below, image

annikoff commented 7 years ago

Hi. Try due_date_change.try(:first).present?

yingsheng658 commented 7 years ago

Hi @annikoff ,

Seems like it still cannot work,need your kindly support also,thanks in advanced. image

annikoff commented 6 years ago

Hi. This works for me without errors.

count = cfs[2].to_i
due_date_changed? && due_date_change.try(:first).present? ? count + 1 : count
yingsheng658 commented 6 years ago

Hi @annikoff,

I did the setting in the Bitnami Redmine Stack v3.2.1-1 but still got failed.Could you give a me a favor how to debug this issue?or maybe it's related to redmine environment,I never met this issue before in another redmine system,thanks in advanced.

annikoff commented 6 years ago

Maybe this will work.

count = cfs[2].to_i
due_date_changed? && due_date_change.is_a?(Array) && due_date_change.first.present? ? count + 1 : count
yingsheng658 commented 6 years ago

Hi @annikoff,

I just try it as you mentioned but still cannot work.Need your support also. image

annikoff commented 6 years ago

I think I've got. Do cfs[2] exists? I suppose it would be the current ID for this field. Try to create a custom field with this formula:

count = 0
due_date_changed? && due_date_change.try(:first).present? ? count + 1 : count

After save set your final formula.

yingsheng658 commented 6 years ago

Hi @annikoff,

Understood,it's work for me,thanks for your kindly support.