Learn to configure the <url_template> element for Pull Reports™ Ad Hoc
    report and data service software.
Catalog Configuration Java API analog:  
    ColumnConfigurationBuilder#setUrlTemplate
    
        A <url_template> configures a URL for a <column> value in the
        Export Report REST API. <url_template>s are 
        useful for creating drill-through reports. The URL implementation depends on the report format.
        For instance, the html
        format outputs the URL as an HTML anchor (<a>) element while the
        csv format type outputs the URL as an additional
        column. See the Export Report REST API chapter for more information.
    
<url_template>
                A <url_template> is a
                Freemarker template
                which may reference column values within the result row within template expressions.
                Only references to columns which are guaranteed to be available at runtime are valid.
                These are:
            
                    Base table columns: 
                     Reference the report's base table columns
                        with @ prefixed column ids.
                        For example: reference a base table <column> with id="name"
                        with ${@name}.
                    
                    Parent tables columns: 
                     Reference the <url_template> parent table columns
                        with @@ prefixed column ids.
                        For example: reference a parent table date <column> with id="some_date"
                        with ${@@some_date?date}.
                        Note ?date is Freemarker date format.
                
@ or @@ within base table <url_template>s
                When creating <url_template>s for <column>s within the <report>'s base table, 
                it is permitted to refer to base table columns prefixed with either @ or @@. The 
                former, @, always refers to columns within the base table. The later, @@,
                always refers to columns within the parent 
                table - which is the base table in this case. The choice between the two prefixes is unimportant unless
                the base table is a global table which is itself referenced by 
                base and non-base <table_ref>s. In this case, prefix column references
                in the global table's <url_template>s with @@ to have them refer to
                <column> idss within the global table.
                
To only export a URL when a referenced column is non-null, use the Freemarker ??
                    operator with an <#if > statement. For example, in
                this <column> definition, the @addressStreet column is only exported as
                    a URL if the @addressId column is non-null.
<column id="addressStreet" name="address_street" displayName="Street Address"> <url_template><![CDATA[<#if @addressId??>/addressLookup?id=${@addressId}</#if></url_template>]]> </column>
Use methods provided by RequestMethodModels to contextualize
                    urls to the HttpServletRequest.
<url_template> values
                Since <url_template> values are filled for each result row, any 
                java.lang.Exception thrown when
                processing the template will disrupt the HTTP response stream and cause an
                invalid response.  For this reason, Pull Reports™ catches all <url_template> 
                processing Exceptions, logs the Exception, 
                and outputs "ERROR. Check log." instead of the true column value.
                
In order to prevent repetitive log entries, Pull Reports™ logs only one 
                <url_template> processing Exception
                per export request.
<url_template> usageThis example demonstrates two <url_template> elements, one associated 
            with the <report>'s base table and 
            one associated with a child <relationship>.
            The former demonstrates a hyperlink into an external URL and the latter
            demonstrates a hyperlink into another Pull Report within the same <catalog>.
            
<?xml version="1.0" encoding="UTF-8"?> <catalog xmlns="http://www.pullreports.com/catalog-1.7.0" id="class_info" name="Class Information" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.pullreports.com/catalog-1.7.0 https://www.pullreports.com/docs/xsd/pullreports-catalog-1.7.0.xsd"> <report id="student" name="Student Report" > <export_config defaultColumns='id,complete_name'/> <table id="student" name="class_info.student" displayName="Student"> <column id="id" name="id" displayName="Student ID" paramType="java.lang.Integer"/> <column id="complete_name" name="complete_name" displayName="Complete Name"> <!-- ${@id} references column class_info.student.id. ${@@id} would also be valid. --> <url_template>https://www.school-district.com/rest/api/student/${@id}.html</url_template> </column> <relationship> <join_column columnName="student_id" referencedColumnName="id" /> <table id="grade" displayName="Grade" name="class_info.grade"> <column id="id" name="id" displayName="Grade ID" paramType="java.lang.Integer" export="false"/> <column id="grade" name="grade" displayName="Grade"/> <column id="year" name="year" displayName="Year" paramType="java.lang.Integer"> <!-- ${@id} references column class_info.student.id. ${@@year} references column class_info.grade.year The <#if> check ensures both ${@id} and ${@@year} are non-null for Pull Reports to output the URL. Although it is not used in this <url_template> example, ${@@id} would reference class_info.grade.id --> <url_template><![CDATA[ <#if @id?? && @@year??> //${getServerName()}/${getContextPath()}/pullreports/catalog/class_info/report/evidence/export?format=htmltable&columns=%2Fevidence&filter=%40student_id%3D${@id}&filter=%2Fevidence%40year%3D${@@year} </#if> ]]></url_template> </column> </table> </relationship> </table> </report> <report id="evidence" name="Grade Evidence Report" > <table id="student" name="class_info.student" displayName="Student"> <column id="student_id" name="id" displayName="Student ID" paramType="java.lang.Integer"/> <column id="complete_name" name="complete_name" displayName="Complete Name"/> <relationship join="inner"> <join_column columnName="student_id" referencedColumnName="id" /> <table id="evidence" displayName="Evidence" name="class_info.grade_evidence"> <column id="year" name="year" displayName="Year" paramType="java.lang.Integer"/> <column id="evidence" name="evidence_text" displayName="Evidence"/> </table> </relationship> </table> </report> </catalog>
To demonstrate the actual URL output, start with the <report>'s base, student table 
            with rows:
student table rows| id | complete_name | 
|---|---|
| 1 | Sylvia Martinez | 
| 2 | Roger Mullins | 
| 3 | Jackie Besanceney | 
Then the URL values for the rows will be:
student table with URL values| id | complete_name | complete_name's URL | 
|---|---|---|
| 1 | Sylvia Martinez | https://www.school-district.com/rest/api/student/1.html | 
| 2 | Roger Mullins | https://www.school-district.com/rest/api/student/2.html | 
| 3 | Jackie Besanceney | https://www.school-district.com/rest/api/student/3.html | 
Then assume a grade table with rows:
grade table rows| id | student_id | grade | year | 
|---|---|---|---|
| 100 | 1 | A | 2014 | 
| 101 | 1 | A- | 2015 | 
| 102 | 2 | B | 2015 | 
The two tables may be joined via the Export Report REST API URL:
/[context]/pullreports/catalog/class_info/report/student/export?columns=/grade
And the joined result rows will be:
student to gradetable left join with <url_template>s applied| id | complete_name | complete_name's URL | grade | year | year's URL | 
|---|---|---|---|---|---|
| 1 | Sylvia Martinez | https://www.school-district.com /rest/api/student/1.html | A | 2014 | //[serverName]/[context]/pullreports/catalog/class_info/report/evidence/export? format=htmltable &columns=%2Fevidence &filter=%40student_id%3D1 &filter=%2Fevidence%40year%3D2014 | 
| 1 | Sylvia Martinez | https://www.school-district.com /rest/api/student/1.html | A- | 2014 | //[serverName]/[context]/pullreports/catalog/class_info/report/evidence/export? format=htmltable &columns=%2Fevidence &filter=%40student_id%3D1 &filter=%2Fevidence%40year%3D2015 | 
| 2 | Roger Mullins | https://www.school-district.com /rest/api/student/2.html | B | 2015 | //[serverName]/[context]/pullreports/catalog/class_info/report/evidence/export? format=htmltable &columns=%2Fevidence &filter=%40student_id%3D2 &filter=%2Fevidence%40year%3D2015 | 
| 3 | Jackie Besanceney | https://www.school-district.com /rest/api/student/3.html | 
<url_template> usage
            <url_template>s may use Freemarker
            directives
                to fulfill complex use cases.
                The following Pull Reports™ XML Catalog file demonstrates directive usage.
            
<?xml version="1.0" encoding="UTF-8"?> <catalog xmlns="http://www.pullreports.com/catalog-1.7.0" id="catalog" name="Catalog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.pullreports.com/catalog-1.7.0 https://www.pullreports.com/docs/xsd/pullreports-catalog-1.7.0.xsd"> <report id="report" name="Report" > <export_config defaultColumns='id'/> <table id="some_table" name="schema.table1" displayName="Table1"> <column id="id" name="id" displayName="ID" paramType="java.lang.Integer"/> <column id="date1" name="date1_field" displayName="Date 1" paramType="java.sql.Date"/> <column id="string1" name="string1_field" displayName="String 1"> <!-- Demonstrates use of Freemarker '?string[...]' and '?url' methods --> <url_template><![CDATA[ /foo/bar?param1=${@date1?string['yyyy']}¶m2=${@string1?url('ISO-8859-1')} ]]></url_template> </column> <column id="string2" name="string2_field" displayName="String 2"> <!-- Demonstrates conditional logic --> <url_template>/foo2/bar2/${@id}${(@date1??)?then('/' + @date1?string['MM'],'')}</url_template> </column> <column id="integer1" name="integer1_field" displayName="Integer 1" paramType="java.lang.Integer"/> <relationship> <join_column columnName="ref_id" referencedColumnName="id" /> <table id="table2" displayName="Table2" name="schema.table2"> <column id="code" name="code" displayName="Code"/> <column id="name" name="name" displayName="name"> <!-- Demonstrates referencing columns on this relationship table and the <report>'s base table --> <url_template><![CDATA[ //www.acme.com/path1?code=${@@code}&date1=${@date1?date} ]]></url_template> </column> </table> </relationship> </table> </report> </catalog>
<column> |