Plugin computed custom field
Added by linkem itsystem over 6 years ago
Hi, I have installed the computed custom field plugin and I'm trying to calculate a time interval; anyone know if it's possible, and how i can calculate difference between two date fields?
This is my environment:
Redmine version 3.4.6.stable
Ruby version 2.4.4-p296 (2018-03-28) [x64-mingw32]
Rails version 4.2.8
Actually, when I try to save a new date custom field with computed option active and minus operator between two date custom fields, I receive this message: Formula undefined method `-' for nil:NilClass.
Thank you all for the support.
Replies (12)
RE: Plugin computed custom field - Added by Matteo Turra almost 5 years ago
I have the same issue. Did you solve it?
RE: Plugin computed custom field - Added by Jérôme BATAILLE almost 5 years ago
Hi, can you give us the source code you typed in the formula ?
On which Model do you use the computed custom field ? issues ?
RE: Plugin computed custom field - Added by Matteo Turra almost 5 years ago
I tried an integer custom field on issues with
self.project_idformula or simply with
1+1, but the field on the issue is always null.
RE: Plugin computed custom field - Added by Jérôme BATAILLE almost 5 years ago
Hi,
Can you make a test with a Text Format Custom Field and use in the formula :
self.inspect
And give the result ?
- I think you have to test on nil because when creating the Custom Field, the issue attached is probably totally blank :
(self.updated_on - self.created_on) if self.updated_on && self.created_on
RE: Plugin computed custom field - Added by Matteo Turra almost 5 years ago
No result with
self.inspect
RE: Plugin computed custom field - Added by Jérôme BATAILLE almost 5 years ago
Hi,
What do you mean ?
You could add a new Text custom field, and you edited an issue and the result in the custom field is empty, instead of having a description of the issue object ?
Aside from that, the solution with the test should work.
RE: Plugin computed custom field - Added by Matteo Turra almost 5 years ago
OK, I didn't understand the fields are computed on saving issue, not during the view phase.
Sorry.
RE: Plugin computed custom field - Added by Jérôme BATAILLE almost 5 years ago
So all is ok for you ? We can close this issue ?
RE: Plugin computed custom field - Added by Matteo Turra almost 5 years ago
Yes. Thanks.
May be in the docs you could specify this behavior.
RE: Plugin computed custom field - Added by Jérôme BATAILLE almost 5 years ago
I'm not the maintainer of this plugin :-)
RE: Plugin computed custom field - Added by Jérôme BATAILLE almost 5 years ago
May be in the docs you could specify this behavior.
It's written in the readme : A valid formula is a valid Ruby code executed when a customized object is updated.
RE: Plugin computed custom field - Added by Shariqh Shaikh over 4 years ago
Jérôme BATAILLE wrote:
Hi,
Can you make a test with a Text Format Custom Field and use in the formula :
[...]And give the result ?
- I think you have to test on nil because when creating the Custom Field, the issue attached is probably totally blank :
[...]
Hi Jérôme BATAILLE,
The output we get according to your formula in is what time unit ??