annikoff/redmine_plugin_computed_custom_field

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

yingsheng658 opened this issue · 8 comments

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

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

Hi @annikoff ,

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

Hi. This works for me without errors.

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

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.

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

Hi @annikoff,

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

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.

Hi @annikoff,

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