MomentJS is a JavaScript library which helps in parsing, validating, manipulating and displaying date/time in JavaScript. Its parsing allows you to parse the date in the format required. Parsing of date is available in the string, object and array. You can use the method isValid() and check whether the date is valid or not. MomentJS also provides… Continue reading Date format using moment.js
Category: Suite scripts samples
All the samples related to suite scripts.
Java Script – encodeURI() & decodeURI()
encodeURI():This function encodes a URI by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character. It returns a new string representing the provided string encoded as a URI. This method does not encode characters like: , / ? : @ & = + $ * #Use the encodeURIComponent() method instead. decodeURI():This function… Continue reading Java Script – encodeURI() & decodeURI()
Add new line at the end of a sublist.
First load the record in dynamic mode.To select the new line at the end of a sublist in any record we can use,record.selectNewLine(options).After selecting the new line in sublist, set the sublist value using,objRecord.setCurrentSublistValue(options).Then to commits the currently selected line on the sublist use,objRecord.commitLine(options)Finally save the record. Example code of estimate record is added below.
Code Portability: Implement environment aware constants file.
Sample of custom module constant file we can use any environment (sandbox and Production). It will only need to find out the constant in the environment and set it in the constant files.
To hide remove button on the item sublist and disable a field.
To hide “REMOVE button” on the item sublist To unhide “REMOVE button” on the item sublist To disable a field in a sales order (variable_name is variable into which the value of the required field is get.) To enable a field in a sales order.
To Make Code Portable
We can create a constants library file like below and add internal ids in objects for different environments.
Handle commas in a saved search result from the NSCONCAT function
Recently, I had to fetch some URLs and file names stored in a custom record related to another record. The challenge was to handle the commas inserted using the NSCONCAT function.My solution was to use the string.replace() function to replace commas in the file names with ‘%2C’ and URLs before concatenating the search result and… Continue reading Handle commas in a saved search result from the NSCONCAT function
How to get related fields of another record while creating a transaction saved search?
For an example, while creating an invoice search the required columns includes some fields incustomer record. The code shows, how to join customer record fields to invoice search.
Inventory Count Record
The Inventory Count feature supports improved tracking of inventory and tighter control over assets. When this feature is enabled, you can enter regular periodic counts of on-hand item quantities to maintain inventory accuracy. Keeping an accurate item count can help reduce required safety stock, which lowers your overhead costs. We can create an inventory count… Continue reading Inventory Count Record
How to set the price level as a custom only for a particular shipping method
How to set the price level as a custom only for a particular shipping method