How can I track which fields have been edited in Netsuite when syncing NetSuite sales orders to Salesforce?

If you have a limited set of fields to check you can make use of the old record. Rough idea below: function afterSubmit(context) { const oldRec = context.oldRecord; const newRec = context.newRecord; const updateSpec = getBodyChanges(newRec, oldRec); updateSpec.lines = []; // similar idea for lines but you also have to make sure lines (checking lineuniqekey)… Continue reading How can I track which fields have been edited in Netsuite when syncing NetSuite sales orders to Salesforce?

Conversion of larger amounts to words using script

To convert large amounts to words, First get the amount from the required field. Use the following function to convert the amount to words. function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } function convertToWords(number) { // Array of units for conversion const units = [”, ‘thousand’, ‘million’, ‘billion’, ‘trillion’, ‘quadrillion’, ‘quintillion’]; // Function to convert… Continue reading Conversion of larger amounts to words using script

Custom Error throwing using N/error in SuiteScript

define([‘N/error’],     /**  * @param{error} error  */     (error) => {         /**          * Defines the function definition that is executed before record is submitted.          * @param {Object} scriptContext          * @param {Record} scriptContext.newRecord – New record    … Continue reading Custom Error throwing using N/error in SuiteScript

Suitelets and UI Object Best Practices

The following are best practices for Suitelet development using UI objects and custom UI. General Suitelets are ideal for generating NetSuite pages (forms, lists), returning data (XML, text), and redirecting requests.Limit the number of UI objects on a page (< 100 rows for sublists, < 100 options for on demand select fields, < 200 rows… Continue reading Suitelets and UI Object Best Practices

Setting the class column in item sub list as mandatory from Company preferences through script

User may set the Class Field to mandatory by ticking the Make Classes Mandatory field on Setup > Accounting > Accounting Preferences > General tab. This can also be done via SuiteScript. var accountingPref = config.load({‌type: config.Type.ACCOUNTING_PREFERENCES}); accountingPref.setValue({‌fieldId: ‘CLASSMANDATORY’,value: true}); accountingPref.save();