Welcome to NetSuite tips and tricks. In today’s SuiteUp post, we will guide you how to show a different date format in NetSuite advanced PDF templates.
In the world of enterprise resource planning (ERP) systems, NetSuite is renowned for its powerful features and flexibility. One common requirement for businesses is the ability to show a different date format in advanced PDF templates.
In this blog post, we will explore how you can leverage the capabilities of Freemarker and advanced PDF templates in NetSuite to show dates in different formats in PDF documents.
Understanding Freemarker and NetSuite Advanced PDF Templates:
Freemarker is a powerful template engine that enables dynamic content generation. It provides a wide range of functions for manipulating and displaying data. The Advanced PDF/HTML Templates provide an alternate method for customizing printed and emailed transactions. This method supports more customization capabilities than basic layouts.
Utilizing the date_format Setting to Show A Different Date Format
We can control how dates are displayed in the PDF template using the date_format setting. This setting allows you to specify a format string that determines the presentation of the date. The format string utilizes a combination of letters, symbols, and placeholders to define the desired format.
Common Format Symbols:
- “d” represents the day of the month as a number (e.g., 01, 02, …, 31).
- “M” represents the month as a number (e.g., 01, 02, …, 12).
- “MMM” represents the abbreviated month name (e.g., Jan, Feb, …, Dec).
- “yyyy” represents the year as a four-digit number (e.g., 2021, 2022, …).
Example Usage: Let’s consider an example where you want to display the current date in the format “DD-MMM-YYYY” (e.g., 07-Jun-2023) instead of the system format date “MM/DD/YYYY” (eg. 06/07/2023)
- Open the advanced PDF template in NetSuite.
- Locate the section where the date needs to be displayed.
- Add the following Freemarker code snippet:
<#setting date_format="DD-MMM-YYYY">
${record.trandate}
In the above code, we set the date_format to “DD-MMM-YYYY” and then we use the ${record.trandate}
expression to retrieve and format the current date using the specified format.
Being able to display dates in various formats is an essential requirement for many businesses using NetSuite. By leveraging the date_format setting in Freemarker and advanced PDF templates, you can easily achieve this flexibility. Whether you need to showcase dates in a specific layout or adhere to local conventions, understanding and utilizing the date_format setting empowers you to present dates precisely as desired.
Remember to explore the available symbols, experiment with different format strings, and refer to the NetSuite documentation as well as Freemarker (opens in new tab) website for more in-depth guidance on date formatting.