Search code examples
netsuitesuitescriptsuitescript2.0saved-searches

How to you print one Result on the Advanced PDF Template from a Saved Search vs a list?


I have an Inbound Shipment saved search of items coming in listed by container. I have no problem printing the list of the items with quantities, description, etc. but when I add in the "vessel Number" or "shipment number" I don't need it to repeat on every line. I would prefer to show the information that I would normally "group" at the top of the PDF vs. on each line.

I should note that when I print the saved search, I would have already filtered the search down to one container, meaning only one "shipment number" and one "vessel number".

<table align="center" border=".5" cellpadding=".5" cellspacing=".5" class="NATIVE-TABLE" style="width:100%;"><#list results as result><#if result_index == 0>
<thead>
    <tr>
    <th align="center" scope="col" style="width: 107px;">
    <div><big>Shipment #</big></div>
    </th>
    <th align="center" scope="col" style="width: 103px;">
    <div><big>Status</big></div>
    </th>
    <th align="center" scope="col" style="width: 156px;">
    <div><big>Destination</big></div>
    </th>
    <th align="center" scope="col" style="width: 150px;">
    <div><big>Actual Ship Date</big></div>
    </th>
    <th align="center" scope="col" style="width: 154px;">
    <div><big>Expected Delivery Date</big></div>
    </th>
    <th align="center" scope="col">
    <div><big>Carrier</big></div>
    </th>
    <th align="center" scope="col">
    <div><big>Vessel #</big></div>
    </th>
    </tr>
</thead>
</#if><tr>
    <td align="center" style="width: 107px;">${result.shipmentnumber}</td>
    <td align="center" style="width: 103px;">${result.status}</td>
    <td align="center" style="width: 156px;">${result.custrecord142}</td>
    <td align="center" style="width: 150px;">${result.actualshippingdate}</td>
    <td align="center" style="width: 154px;">${result.expecteddeliverydate}</td>
    <td align="center" style="width: 154px;">${result.custrecord_htd_shipper_info}</td>
    <td align="center" style="width: 154px;">${result.vesselnumber}</td>
    </tr>
    </#list></table>

Solution

  • First: please post your code so we can see where you're up to and respond accordingly - it helps us to help you!

    Second: The general pattern would be that you simply use values from the first result to make up your header, and then iterate through all results to give your lines. It would look something like:

    <#list results as result>
        <#if result_index == 0>
            *header information goes here*
        </#if>
            *line information goes here*
    </#list>
    

    Edited to add code

    <table align="center" border=".5" cellpadding=".5" cellspacing=".5" class="NATIVE-TABLE" style="width:100%;"><#list results as result><#if result_index == 0>
        <thead>
            <tr>
            <th align="center" scope="col" style="width: 107px;">
            <div><big>Shipment #</big></div>
            </th>
            <th align="center" scope="col" style="width: 103px;">
            <div><big>Status</big></div>
            </th>
            <th align="center" scope="col" style="width: 156px;">
            <div><big>Destination</big></div>
            </th>
            <th align="center" scope="col" style="width: 150px;">
            <div><big>Actual Ship Date</big></div>
            </th>
            <th align="center" scope="col" style="width: 154px;">
            <div><big>Expected Delivery Date</big></div>
            </th>
            <th align="center" scope="col">
            <div><big>Carrier</big></div>
            </th>
            <th align="center" scope="col">
            <div><big>Vessel #</big></div>
            </th>
            </tr>
        </thead>
        <tr>
            <td align="center" style="width: 107px;">${result.shipmentnumber}</td>
            <td align="center" style="width: 103px;">${result.status}</td>
            <td align="center" style="width: 156px;">${result.custrecord142}</td>
            <td align="center" style="width: 150px;">${result.actualshippingdate}</td>
            <td align="center" style="width: 154px;">${result.expecteddeliverydate}</td>
            <td align="center" style="width: 154px;">${result.custrecord_htd_shipper_info}</td>
            <td align="center" style="width: 154px;">${result.vesselnumber}</td>
            </tr>
        </#if>
            <tr>
            <td align="center" style="width: 107px;"></td>
            <td align="center" style="width: 103px;">${result.status}</td>
            <td align="center" style="width: 156px;">${result.custrecord142}</td>
            <td align="center" style="width: 150px;">${result.actualshippingdate}</td>
            <td align="center" style="width: 154px;">${result.expecteddeliverydate}</td>
            <td align="center" style="width: 154px;">${result.custrecord_htd_shipper_info}</td>
            <td align="center" style="width: 154px;"></td>
            </tr>
        </#list>
    </table>