NVelocity Issue

197 views Asked by At

I have taken over some work on an existing system that uses NVelocity templates. It iterates though some rows of data and then loops though the fields creating an html table of the data. I want to change this so that some of the table cells contains data from a different field.

here is how it works:

#if($data.Count > 0)
    #set ($end = $data.Count - 1)
    #foreach($count in [0 .. $end])
        <tr class="$!class $!alerts $!status">
        #set($colcount = 0)
        #foreach($field in $fields)
            <td class="$!colclass">
                $data.GetData($count, $field)
            </td>
        #end
        </tr>
    #end
#end

What I want it to do something like this :

#if($data.Count > 0)
    #set ($end = $data.Count - 1)
    #foreach($count in [0 .. $end])
        <tr class="$!class $!alerts $!status">
        #set($colcount = 0)
        #foreach($field in $fields)
            #if($field.Name=="JourneyAlias")
                $data.GetData($count, $field) - $data.GetData($count, 'JourneyId')
            #else
                <td class="$!colclass">
                    $data.GetData($count, $field)
                </td>
            #end
        #end
        </tr>
    #end
#end

In short I want to know how to access the field JourneyId from the data

1

There are 1 answers

0
Andy Stannard On BEST ANSWER

Sorted the issue I needed this syntax:

#set($journeyid = $data.DataItem($count).JourneyID)