Client Script for Extracting Values from URL

function setContactForm(type) { try { // Corrected typo in variable name ‘typee’ to ‘type’ if (type === ‘create’) { var form = nlapiGetFieldValue(‘customform’); // Renamed GetUrlValue to match the actual function name getQueryVariable var recordType = getQueryVariable(‘parentType’); // If the form is already the desired one, stop the script if (form == 178 && recordType… Continue reading Client Script for Extracting Values from URL

Difference Between nlapiGetCurrentLineItemValue or record.getCurrentSublistValue and nlapiGetLineItemValue or record.getSublistValue

There are two functions for accessing line items in sublists.   For SuiteScript 1.0: nlapiGetCurrentLineItemValue() and nlapiGetLineItemValue()   For SuiteScript 2.0: record.getCurrentSublistValue() and record.getSublistValue()   These two functions perform the same in most contexts except Client scripts. In Client scripts, the retrieved values can be different.    The nlapiGetCurrentLineItemValue() or record.getCurrentSublistValue() should be used to pull the new value… Continue reading Difference Between nlapiGetCurrentLineItemValue or record.getCurrentSublistValue and nlapiGetLineItemValue or record.getSublistValue

Suitelet sample for fetching and displaying values from an external API in a Suitelet page

Suitelet Script /** * @NApiVersion 2.1 * @NScriptType Suitelet */ define([‘N/ui/serverWidget’, ‘N/https’],     (serverWidget, https) => {           const onRequest = (scriptContext) => {             try {                 if (scriptContext.request.method === ‘GET’) {          … Continue reading Suitelet sample for fetching and displaying values from an external API in a Suitelet page

Pagination in a Suitelet page using a SELECT field in the form to select page number – Simplified

This code will dynamically change the data according to the selected page number using Suitelet and Client Scripts. Sample search is used in the code ni order to set the sublist values. Suitelet code: Create a select field for pagination let selectPageField = form.addField({ id: ‘custpage_page_select’, type: serverWidget.FieldType.SELECT, label: ‘Select Page’ }); // Get current… Continue reading Pagination in a Suitelet page using a SELECT field in the form to select page number – Simplified

Enhancing Purchase Orders: Storing Child Records for Sublist Display using Suitelet

Create a child record for the standard record which is the purchase order. Make all the fields to be show in list. Custom Field Display should be normal. Here is the child record and the purchase order connects with the corresponding purchase order. Suitelet Code: /**  * @NApiVersion 2.1  * @NScriptType Suitelet  */ /**************************************************  *… Continue reading Enhancing Purchase Orders: Storing Child Records for Sublist Display using Suitelet

Function to check duplicate manufacturer records

Function to check duplicate manufacturer records in NetSuite. function checkForDuplicateManufacturers(currentRecord) { try{         var catalogItemsObj = {};         var manufacturerName = currentRecord.getValue({ fieldId: ‘name’ });         var normalizedName = removeSpecialCharacters(manufacturerName);         var manufacturerSearch = search.create({             type: ‘customrecord_mhi_ibs_manufacturers’,… Continue reading Function to check duplicate manufacturer records

ReferenceError fieldChanged is not defined in SuiteScript 1.0

Introduction When working with NetSuite’s SuiteScript 1.0, developers may encounter unexpected errors that disrupt the functionality of custom scripts. One such error is the “fieldChanged is not defined” error, which can occur even if the functions are properly defined. This article will guide you through understanding the cause of this error and how to resolve… Continue reading ReferenceError fieldChanged is not defined in SuiteScript 1.0

How to get the field values in custom function in client script

Scenario: You have to get the field values from the record/form in a custom function in the client script. Getting the value directly from the scriptContext is not possible in a custom function. In these cases, we use currrentRecord module. Solution: function customFunction() {     let currentRec= currentRecord.get(); let fieldValue= currentRec.getValue({ fieldId: ‘custpage_field’ }); } Here… Continue reading How to get the field values in custom function in client script

Accessing cookies in client script

The following function can be used to access cookies value in client script: const sessionCheckScript = ‘<script>’ +      ‘function getCookie(name) {‘ +     ‘const value = “; ” + document.cookie;’ +      ‘const parts = value.split(“; ” + name + “=”);’ +      ‘if (parts.length === 2) return parts.pop().split(“;”).shift();’ +        ‘}’ +     ‘var sessionToken = getCookie(“session_token”);’ +      ‘if… Continue reading Accessing cookies in client script

To find if any changes has been made to a suitelet form

Scenario: I have created a suitelet form to edit a particular record. If there are no changes in the form, I have to block the submission and display a warning. Solution: Link a client script file to the necessary suitelet page and in the client script page give the below code. define([‘N/log’, ‘N/ui/dialog’], function (log,… Continue reading To find if any changes has been made to a suitelet form