Preventing Duplicate Record Creation on Form Resubmission

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

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

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)