Template How to??

(5 posts) (2 voices)

Tags:

No tags yet.

  1. chiacy, Member

    I am trying to apply template using your sample, i.e. invoice form but not avail.

    I defined the template via web, where only the header is defined, with the sample invoice header provided as below:

    Created a template called etiuae_invoice, the following code is kept under the header tab.

    <table style="margin-top: 40px;margin-bottom: 30px">
    <tr>
    <td rowspan=3>

    </td>
    <td style="padding-left:10px" rowspan=3>
    <span style="font-size:2em">#company</span>
    #address
    </td>
    <td colspan=3> </td>
    </tr>

    <tr>
    <td style="width:220px"></td>
    <td style="text-align:right"><b>#{DATE}:</b></td>
    <td style="text-align:right">#date</td>
    </tr>

    <tr style="vertical-align: top;">
    <td style="width:220px"></td>
    <td style="text-align:right"><b>#{INVOICE} #:</b></td>
    <td style="text-align:right">#invoice_nbr</td>
    </tr>
    </table>

    Then in the report, I inserted the following:

    select 'dbr.template', '#etiuae_invoice';

    select 'Company Name' as 'company',
    'Address' as address,
    convert(date, getdate(),120) as date,
    convert(char(10), getdate(),112) as invoice_nbr

    It seems all template variables show up as it is, i.e. #company, #address, #{DATE}:, #date, #{INVOICE} #:, #invoice_nbr

    which they were not replaced accordingly by the following select statement which

    #company should be 'Company Name' etc.

    Please advise

  2. myDBR Team, Key Master

    Hi,
    when you use a template, there is three different sections you can use: header, row and the footer.

    The header is a section that is used before any of the result set rows are processed. It is included once into the report.

    The row-section is repeated for each row in the result set. The row-section can include the template variables.

    Finally, after all the rows are processed, the footer-section is included.

    If your result set query produces only one row, you do not need to separate header, row and the footer, but you can put all in the row-section.

    --
    myDBR Team

  3. chiacy, Member

    My problem is :

    somehow the template variable is not replacing by the correct value from the select statement, eg.

    <td>#company</td>

    where my select statement is

    select 'ABC Co' as company

    eg.

    I stored the following in template : test, header section

    <table style="margin-top: 40px;margin-bottom: 30px"> <tr> <td rowspan=3> </td> <td style="padding-left:10px" rowspan=3> <span style="font-size:2em">#[User]</span>

    </td> <td colspan=3> </td> </tr> </table>

    then on report stored procedure,

    select 'dbr.template', '#test';
    select 'test' as [User]

    and the result showing #User instead of 'test'

    Please advise

  4. myDBR Team, Key Master

    Chiacy,
    parameter substitution takes place in templates 'row'-section, not in the 'header'-section.

    When you have only one row returned, you can put the full template in the 'row'-section. When you have multiple rows, the 'header' section handles definitions before any data, and 'footer'-section handles definitions after the data. Variable substitions in this case also happen in the 'row'-section.

    --
    myDBR Team

  5. chiacy, Member

    thanks a lot, got it :)


Reply

You must log in to post.