Get your own customer support community
 

Eval-data not working in reporting macros

Hi I'm having a problem with getting {eval-data} to work inside a reporting macro.

Free-standing the following works perfectly and produces the expected result "5":
{eval-data:Sum}2+3{eval-data}


However, this does not work:
{report-on:injected=true}
{report-table}
{content-reporter:space=@self|types=page|scope=Folk > children|labels=person}
{text-sort:page:title|order=ascending}
{content-reporter}
{report-column:title=Navn}{report-info:page:title|link=true}{report-column}
{report-column:title=Rolle}{report-info:data:Rolle}{report-column}
{report-column:title=Timeforbruk}{eval-data:Sum2}
{report-block}
{local-reporter:data:Timer}
{date-filter:data:Dato|minValue=%data:Start%|maxValue=%data:Stopp%|format=EEE MMM dd HH:mm:ss zzzz yyyy|required=true}
{local-reporter}
{report-body}{report-info:data:Antall}+{report-body}
{report-empty}0{report-empty}
{report-block}0{eval-data}
{report-column}
{report-empty}Ingen oppgaver.{report-empty}
{report-table}
{report-on}


The nested report produces a string like "2+3+0" inside an {eval-data} macro, but gives no result or error when being rendered. If I remove just the {eval-data} fields the expression is printed correctly, but naturally not evaluated.

I'm thinking the problem is related to {eval-data} being rendered before the inner report, and thus no valid expression is available to evaluate, but that should have resulted in an error from {eval-data} of which there are none. This leaves me puzzled.

I know that the new Reporting 3.2.0 has a Stats-supplier that could let me do this math, but we're still on Confluence 2.9 so that is unfortunately not an option yet.

If no solution exists using {eval-data} I'm prepared to make a custom macro to sum the numbers instead. I've experimented with this already by creating a {sum} macro that takes the expression as body, as shown below, but for some reasong this isn't working either due to an error in the Velocity code which I can't identify.
#set ($Integer = 0)
#set ($sum = 0)
#set ($numbers = $body.split(","))
#foreach ($string in $numbers)
#set ($sum = $sum+$Integer.parseInt($string))
#end
$sum


Please assist.
 
silly I’m puzzled
Inappropriate?
1 person has this question

User_default_medium