Goal: Dynamically change invoice PDF logo based on...
# advancedpdf
s
Goal: Dynamically change invoice PDF logo based on the location on the transaction header. Challenge: We can pull address etc. however we can’t get the logo loaded. Workaround: We have a custom body field with formula to source the information, and then we’re using that to get it to work. QUESTION: has anyone been able to get the url to load the logo directly into AdvancedPDF without custom body or record field?
Ran into a couple of things when we were doing testing. First, even if you add custom fields on the location record, for whatever reason, you still can’t source them in Advanced PDF. Therefore we were forced to create hidden custom transaction body fields. If anyone figures out a better solution, let me know. Until then this is what we’re doing. # Dynamic Transaction Template driven by Location Use NetSuite Advanced PDF/HTML transaction to dynamically change transaction logo and address based on Location header field. ## Prerequisites Following features should be enabled • Advanced PDF/HTML Templates • Sales Orders • Check Setup > Company > Printing & Fax > USE LOCATION ADDRESS ON FORMS ## Getting Started To get started, decide the scenario that works best for you: • Create new template in NetSuite UI • Update existing template in NetSuite UI • Use NetSuite Suite Development Framework (SDF) to create/update template ### Usage #### Using UI: - Create custom transaction body fields. - Logo field should be of field type of image, and source value from Location (Main)’s logo field. - Address field should be of type text area, and source value from Location (Main)’s address field. - You can review the [SuiteAnswer ID 61596](https://netsuite.custhelp.com/app/answers/detail/a_id/61596/). - Note
scriptid
of the created fields. - Create/Update Advanced PDF/HTML template. - Replace the code that is similar to
Copy code
<#if companyInformation.logoUrl?length != 0>
              <img src="${companyInformation.logoUrl}" style="float: left; margin: 7px" />
          </#if>
              <span class="nameandaddress">${companyInformation.companyName}</span><br />
              <span class="nameandaddress">${companyInformation.addressText}</span>
with
Copy code
<!-- If Setup > Company > Printing & Fax > USE LOCATION ADDRESS ON FORMS is checked AND location has logo present, then it will use the location logo and address else it will use the company logo and address. -->

          <#if preferences.printlocaddress == true && record.[scriptid for logo field]@url?length != 0>
              <img src="${[scriptid for logo field]@url}" style="float: left; margin: 7px" />
                  <span class="nameandaddress"></span><br />
                  <span class="nameandaddress">${record.[scriptid for address field]}</span>
        <#elseif companyInformation.logoUrl?length != 0>
              <img src="${companyInformation.logoUrl}" style="float: left; margin: 7px" />
                  <span class="nameandaddress">${companyInformation.companyName}</span><br />
                  <span class="nameandaddress">${companyInformation.addressText}</span>
          </#if>
#### Using SDF: If you are using SDF, you already know what you are doing. Download/clone the repo, edit, and push to the environment of your choosing. ## Acknowledgments - [SuiteAnswer ID 61596](https://netsuite.custhelp.com/app/answers/detail/a_id/61596/) - [AdvancedPDf - dynamic transaction logo based on header location](https://www.reddit.com/r/Netsuite/comments/k077ld/advancedpdf_dynamic_transaction_logo_based_on/) - Follow [u/Nick_AxeusConsulting](https://www.reddit.com/user/Nick_AxeusConsulting/)