Scenario : Identified that when the Submit button is clicked, and the user subsequently navigates back to the form using the browser’s Back/Forward button, the previously entered content is still present. If the Submit button is clicked again, a duplicate record is created. Solution: To resolve this issue, we have implemented a solution that clears… Continue reading Preventing Duplicate Record Creation on Form Resubmission
Tag: Clientscript
Prevent Field Editing Based on Condition
/** * @NApiVersion 2.x * @NScriptType ClientScript */ define([‘N/ui/message’], function(message) { function fieldChanged(context) { var currentRecord = context.currentRecord; var fieldId = context.fieldId; if (fieldId === ‘custpage_factor’) { var stage = currentRecord.getValue(‘custpage_stage’); if (!stage) { message.create({ title: “Warning”, message: “You cannot edit the FACTOR field unless STAGE is set.”, type: message.Type.WARNING }).show(); currentRecord.setValue(‘custpage_factor’, ”); } }… Continue reading Prevent Field Editing Based on Condition
Populate Shipping Address Subrecord Values in Transactions Using Script
Scenario: User wants to set the values of Shipping Address subrecord using Client Script for existing records. Solution: /** * * @NApiVersion 2.x * @NScriptType ClientScript * */ define([‘N/record’, ‘N/currentRecord’, ‘N/runtime’], function pageInit(scriptContext) { try { var recordid = scriptContext.currentRecord.id; var recordtype = scriptContext.currentRecord.type; var rec = record.load({ type: recordtype, id: recordid, isDynamic: true });… Continue reading Populate Shipping Address Subrecord Values in Transactions Using Script
Disabling On onbeforeunload Event in PageInit
/** * Function to be executed after page is initialized. * * @param {Object} scriptContext * @param {Record} scriptContext.currentRecord – Current form record * @param {string} scriptContext.mode – The mode in which the record is being accessed (create, copy, or edit) * … Continue reading Disabling On onbeforeunload Event in PageInit
Form.clientScriptModulePath function
Form.clientScriptModulePath function is the relative path to the client script file to be used in this form. Use this property when attaching an on demand client script to a server script. General syntax is as: objForm.clientScriptModulePath = ‘SuiteScripts/formBehavior.js’; Note that the path to be mentioned is the relative path of the file. It is useful… Continue reading Form.clientScriptModulePath function
SuiteScript 2.0 dialog.confirm Alternative
Due to the nature of SuiteScript 2.0’s dialog.confirm box, utilizing it on a record to confirm if the user wants to proceed in saving proves to be difficult. We can make use of native Javascript’s confirm() to achieve similar results albeit not as visually appealing. Below is a sample code showing usage of it on… Continue reading SuiteScript 2.0 dialog.confirm Alternative
Auto populate sales order body level location field to line level location field
function findLineCountAndLoc(currentRecord) { var lineCount = currentRecord.getLineCount({ sublistId: ‘item’ }); var location = currentRecord.getText({ … Continue reading Auto populate sales order body level location field to line level location field
Copy a Value to the Item Column(Client Script)
/** * @NApiVersion 2.1 * @NScriptType ClientScript * @NModuleScope SameAccount */ define([‘N/search’], (search) => { function fieldChanged (context) { try { const recInvoice = context.currentRecord; const stCurrField = context.fieldId; const stCurrSublist = context.sublistId; // Get UPC code of billing item if (stCurrSublist === ‘item’ && stCurrField === ‘custcol_billingitem’) { const billingitem = recInvoice.getCurrentSublistText({ sublistId: ‘item’,… Continue reading Copy a Value to the Item Column(Client Script)
Validation for a field to allow only decimal numbers.
Client script with fieldChanged() entry point can be used.
Remove NetSuite Sublist Button
Client script pageInit() and initLine() functions can use jQuery (automatically included by Netsuite) to find and remove the Remove button. Code Snippet: