Project

General

Profile

How to get value of a custom field?

Added by Matthew Paul almost 7 years ago

I'm hopeless at Ruby, but I'm trying to change an install of the issue_charts plugin to sum the value in a specific field instead of just a count. But not sure how to get at that value?

The issue custom field is called 'Paid', it's id is 10, and it's a float. So the code looks like -

      count = scope.count.to_s if chart.time == 'count'   --- WORKS!
      count = scope.sum(cf[10].value).to_s if chart.time == 'amount_paid' --- total guess, unsurprisingly does not work :-(
      count = scope.sum(:estimated_hours).to_s + ' h' if chart.time == 'estimated_hours'   --- WORKS!

EDIT - sorry I should say that something like this works -

      count = scope.sum(2).to_s if chart.time == 'amount_paid'

i.e. If there are like 10 records it returns the sum of 10 * 2 = 20 - so I know the basic syntax works, I just need to replace that fixed number 2 with the amount in PAID custom field for each issue record.

Any idea on the right syntax to use there??

Thanks!