Formula Fields in Advanced Templates

If you’re Advanced PDFing a saved search, it is not uncommon to include a formula field in your results. Referencing that field is easy if you know where to look.

I needed a report that compared our estimated cost (from the sales order) to the vendor PO where we actually purchased the product. In our business model, those two costs don’t always match. In some cases, we get a rebate. Rebates affect our financial reporting at the sales order level and thus at the sales rep level as well. The standard reports in NetSuite were helpful but fell short of our needs. Time to write a report of my own!

The time-consuming dilemma was mapping formula fields in the saved search results to references in the Freemarker code of an advanced PDF template. It was super easy once I finally figured out where to look. Here is the report. As you can see, I’ve got several calculated fields.

Saved Search Definition

And here’s the trick. When you create your advanced template by clicking “New Template” on your saved search.

New Template.png

Before you switch to source code editing, get a screen print of your mapped field names.

Mapped Field Names

Then, when you switch to source code editing, you have your list of fields which can be referenced in your Freemarker code.

Switch to Source Code Editing

Here’s what that looks like.

Freemarker Code

This is so easy, you might be asking yourself, “Is this worthy of a blog article?” In looking for this answer, I searched on things like “Advanced Template Joins” and “Formula Fields in Advanced Templates.” I found nothing. Hopefully, next time I can’t remember how to do this, I’ll land here!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s