Suitelet to add more functionality and features to custom report: Export to CSV or Excel var csvContent = ‘Sales Order,Customer,Date,Total Amountn’; salesOrderSearch.run().each(function(result) { csvContent += result.getValue(‘tranid’) + ‘,’ + result.getText(‘entity’) + ‘,’ + result.getValue(‘trandate’) + ‘,’ + result.getValue(‘total’) + ‘n’; return true; }); context.response.setHeader({ name: ‘Content-Type’, value: ‘text/csv’ }); context.response.setHeader({ name: ‘Content-Disposition’, value: ‘attachment; filename=”sales_report.csv”‘… Continue reading Enhancing the Suitelet for Custom Reports
Author: Theres Davies
Create Custom Reports with Suitelets
Suitelet to Generate a Custom Sales Report /** * @NApiVersion 2.x * @NScriptType Suitelet */ define([‘N/ui/serverWidget’, ‘N/record’, ‘N/search’, ‘N/render’, ‘N/file’], function(serverWidget, record, search, render, file) { function onRequest(context) { if (context.request.method === ‘GET’) { var form = serverWidget.createForm({ title: ‘Custom Sales Report’ }); var startDateField = form.addField({ id: ‘custpage_startdate’, type: serverWidget.FieldType.DATE, label: ‘Start Date’ });… Continue reading Create Custom Reports with Suitelets
Custom PDF Template in NetSuite using SuiteScript
Create a PDF/HTML template by navigating to: Customization > Forms > Advanced PDF/HTML Templates. After creating template in the NetSuite, use SuiteScript to generate the PDF using this template. For example: /** * @NApiVersion 2.1 * @NScriptType Suitelet */ define([‘N/render’, ‘N/record’, ‘N/file’, ‘N/log’], function(render, record, file, log) { function onRequest(context) { try { var salesOrder… Continue reading Custom PDF Template in NetSuite using SuiteScript
Using Advanced Template Formatting Programmatically
Using Advanced Template Formatting programmatically in SuiteScript, specifically for generating custom PDFs and other documents in NetSuite, requires leveraging the SuiteScript 2.0 API and Advanced PDF/HTML Templates functionality. The process generally involves integrating XML-based template structures with data from NetSuite records. Create a new template, or customize an existing one by writing XML-based HTML to… Continue reading Using Advanced Template Formatting Programmatically
Entering Data in Child Records from the Parent Record
Enter data in child records from the parent record. To do so, open the list of records where parent record appears. Choose one of the following options: If parent record is a custom record: Go to Customization > Lists, Records, & Fields > Record Types. Click the name of the custom record list you want… Continue reading Entering Data in Child Records from the Parent Record
Different Stages of Fixed Asset Management
Assets in NetSuite typically go through several stages during their lifecycle, from acquisition to disposal. These stages help organizations manage and track their assets effectively. Here are the different stages of an asset in NetSuite Acquisition refers to the process by which one company purchases most or all of another company’s shares or assets to… Continue reading Different Stages of Fixed Asset Management
Multiple Columns in Suitelet Pages Using FieldBreakType and FieldLayoutType
FieldBreakType is a property that controls how fields are aligned relative to each other horizontally. It determines whether a field should start a new column, continue in the same column, or end the current column. This property is especially useful when you want to create multi-column layouts in your forms. FieldLayoutType is a property that… Continue reading Multiple Columns in Suitelet Pages Using FieldBreakType and FieldLayoutType
Restrict Vendor Record with Long Name Using Client script
Function for restricting the user from creating a vendor name that is no longer than 74 characters. If a user tries editing a vendor record that already has more than 74 characters, an alert is thrown, and the user can only save the record if the name is shortened to 74. Applicable only to company-type… Continue reading Restrict Vendor Record with Long Name Using Client script
Generate Random Password with Special Characters
Below given function will generate a random password including special characters. function generatePswdString(max, min) { const passwordChars = “0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#@!%& ()/”; const randPwLen = Math.floor(Math.random() * (max – min + 1)) + min; var randomPassword = “”; for (var i = 0; i < randPwLen; i++) { var randomIndex = Math.floor(Math.random() * (passwordChars.length)); … Continue reading Generate Random Password with Special Characters
setValue() vs nlapiSetFieldValue()
nlapiSetFieldValue() is a function in NetSuite’s SuiteScript 1.0 API. It is used to set the value of a field on the current record in the context of a client script or user event script. This function is part of the API that allows developers to interact with and manipulate records within NetSuite. For example: nlapiSetFieldValue(fieldId,… Continue reading setValue() vs nlapiSetFieldValue()