Hi , I am trying to access values from saved searc...
# advancedpdf
s
Hi , I am trying to access values from saved search, adding it via
addSearchResults
, I am able to access the fields after the
<#list>
but not prior. No errors, just no data showing up. How would I got to accessing fields? Below, the entityid isn’t pulling the record, _po_receiving_ is my templateName
Copy code
<table>
                <#list po_receiving![]>
                <th>${po_receiving.entityid}</th>
                <#assign totalQtyRcvd = 0>
                <#assign totalWeightRcvd = 0>

                <tr>
                    <th>Date</th>
                    <th>Document Number</th>
                    <th>Item</th>
                </tr>
                <#items as ir>
                <tr>
                    <td align="left">${ir.trandate}</td>
                    <td align="left">${ir.tranid}</td>
s
<#list po_receiving![] *as ir*> ... </#list>
s
trying to use this outside a table — i assume that’s not possible? getting unexpected error
i also am trying to pull up data thats not going to be in a loop. like po number, vendor and etc. Is that possible with this approach?
s
Copy code
<#if po_receiving?has_content && po_receiving?size gt 0>
   <p>Some header info on the first line only: ${po_receiving[0].tranid} ${po_receiving[0].trandate}</p>
</#if>

<#list po_receiving as items>
    <table>
    <#if po_receiving_index = 0>
        <thead>
             <tr>
                 <th>Heading 1</th>
                 <th>Heading 1</th>
             </tr>
        </thead>
    <#/if>
    <tr>
       <td>${item.item}</td>
       <td>${item.quantity}</td>
    </tr>
     
    <#else> <!-- this will catch occurences where there are no list items -->
        ... do stuff when there are no results
    </#list>
</#list>
just need to index the first line as po_receiving[0]
#items is not a freemarker function
s
argh! dang it. thanks so much. I didn’t know I can access using indexes. i had no problem pulling up the rest of the lines, but some body fields weren’t working and the using index worked for them appreciate taking the time @Stefan Reeder!!
🎉 1
s
In Freemarker, arrays are known as Sequences, while objects are called Hashes
🙌 1
those links are your guide for Advanced PDF
🫡 1
s
thank you so much!