Print to PDF access parent value from each section

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kyle
    Senior Member
    • May 2020
    • 143

    Print to PDF access parent value from each section

    Hi,
    I am having some trouble setting up conditional logic in my PDF template.
    I want a column in the table to only be printed if the parent entity has a taxType of 'Taxed' this works for the header row but I can not seem to get the right syntax from inside the {{#each Item}} section to do this check. Is this possible?


    HTML Code:
    <table border="0.1pt" cellpadding="2" class="table table-bordered">
        <tbody>
            <tr>
                <td>Item</td>
                <!-- {{#ifEqual taxType 'Taxed'}} -->
                    <td align="right">Tax</td>
                <!-- {{/ifEqual}} -->
                <td align="right">Total</td>
            </tr>
            <!-- {{#each Item}} -->
            <tr>
                <td>{{ItemName}}</td>
                <!-- {{#ifEqual this ../taxType 'Taxed'}} -->
                    <td align="right">{{totalTax}}</td>
                <!-- {{/ifEqual}} -->
                <td align="right">{{total}}</td>
            </tr>
            <!-- {{/each}} -->
        </tbody>
    </table>



  • yuri
    Member
    • Mar 2014
    • 8442

    #2
    Hi Kyle,


    Code:
    {{../taxType}}
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • Kyle
      Senior Member
      • May 2020
      • 143

      #3
      Thank you. this worked.

      Comment

      • esforim
        Active Community Member
        • Jan 2020
        • 2204

        #4
        I'm saving this info for future use, but where would you use that code specifically?

        Is it like this?


        Code:
        <!-- {{#ifEqual {{../taxType}} 'Taxed'}} -->

        Comment

        • Kyle
          Senior Member
          • May 2020
          • 143

          #5
          Hi not quite here is the syntax from my template
          HTML Code:
          <table border="0.1pt" cellpadding="2" class="table table-bordered">
              <tbody>
                  <tr>
                      <!-- {{#ifEqual taxType "Taxed"}} -->
                          <td align="right">Tax</td>
                      <!-- {{/ifEqual}} -->
                      <td align="right">Total</td>
                  </tr>
                  <!-- {{#each lineItem}} -->
                  <tr>
                      <td align="right">{{totalTaxCurrencySymbol}}{{discount Amt}}</td>
                      <!-- {{#ifEqual ../taxType "Taxed"}} -->
                          <td align="right">{{totalTaxCurrencySymbol}}{{totalTax }}</td>
                      <!-- {{/ifEqual}} -->
                      <td align="right">{{totalTaxCurrencySymbol}}{{total}}</td>
                  </tr>
                  <!-- {{/each}} -->
              </tbody>
          </table>

          Comment

          • esforim
            Active Community Member
            • Jan 2020
            • 2204

            #6
            Originally posted by Kyle
            Hi not quite here is the syntax from my template
            Thank Kyle, good to see. Also you should probably use the [code] instead of HTML.

            Comment

            Working...