Apps Details

To show data that is not available on the record, a common approach is to create a button which then calls a Suitelet. This Suitelet uses saved searches or queries to generate the data needed on the Advanced PDF and then renders the PDF. This is fine but what if there was a way to natively print the PDF without the need for a custom button?

Solution

Create a User Event Script on the record.  In the beforeLoad function get the data you need using Saved Searches or SuiteQL.  Create a custom field to store the data.

/**
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 * @NModuleScope Public
 *
 */


define([
    'N/record',
    'N/search',
    'N/ui/serverWidget'
]
,  (
    record,
    search,
    serverWidget
) => {
        beforeLoad = (context) => {
			if (context.type == context.UserEventType.PRINT) {
				const newRecord = context.newRecord;
				// Create the custom field to save data
				let dataForPDF = context.form.addField({
					id: 'custpage_data_for_pdf',
					type: serverWidget.FieldType.LONGTEXT,
					label: 'data for pdf'
				});
				dataForPDF.updateDisplayType({ displayType: serverWidget.FieldDisplayType.HIDDEN });

				// Call Search function(s) to get all the data you need.  This should return an object
				let dataObject = getData();
				dataForPDF.defaultValue = JSON.stringify(dataObject);
			}
        }

		getData = () => {
			// get all the data using searches or SuiteQL
			return dataObject;
		}


		return {
            beforeLoad: beforeLoad
        };
});

In the Advanced PDF reference the generated field.  Use “eval” to parse the data into an object.

<#assign data = record.custpage_data_for_pdf?eval> <p> ${data.field}</p>

Conclusion

This simple solution allows you reach data you otherwise would not be able to on an advanced PDF.  It does this without the need for a custom button.

Do you need help with customizing NetSuite?  Suite Tooth Consulting specializes in all sorts of customization for NetSuite including scripting, workflows, advanced PDFs, and integrations.  Get a free consultation.

If you liked this article, please sign up for my newsletter to get these delivered to your inbox here.

FAQ

Your Guide To
Understanding Us Better

Backed by its functional features and proven applications, NetSuite can elevate your enterprise process and accelerate business functions to a great extent! One of the main reasons why you should consider NetSuite customization for your business is because it can boost operational efficiency and make your business more process-centric by optimizing your fragmented enterprise actions in just a single cloud platform.

Just like any other robust software solution, NetSuite customization holds the capacity to address and solve your business pain point – be it a small problem or a complex issue! A reliable and reputed team of NetSuite consultants like us can help you come up with the best strategies and plan to make ERP unleash its full potential to solve your specific business problems.

The design, implementation, and customization strategies of NetSuite might be developed solely on the basis of the specific industry an organization is dealing with. This is dependent on the operational process and size, which comply with every business operation.

Every company has its own unique and distinct business processes, workflows, personalized software needs, and the likes. One of the most remarkable perks of NetSuite is that it’s extremely customizable. If your company requirements are unique or specific, you require trusted NetSuite consultants who hold extensive experience and expertise with robust software development and architecture for making the solution suitable to your requirements.

At Suite Tooth Consulting, we emphasize building a full-fledged strategy to ideate on a plan on action right from the inception until the “go-live” as well as “post-implementation” rescue timetable. Implementing and customizing a robust ERP like NetSuite is a complex and detailed procedure. It can potentially entail a few days or even a few months for more complex builds. As your top-trusted team of consultants, we shall provide you with a detailed forecast or a breakdown of timeline to give you a heads-up on how long our team can potentially take to wrap the entire process.

Get Connected

How can we help?


    Stay in the loop with Suite Tooth Consulting!

    We aim to bring unmatched expertise and professionalism to your NetSuite initiatives. Let’s talk about how our NetSuite consultancy can make a difference!

    Global Client Satisfaction