Use Script Function to Avoid Blank Cells When Generating CSV File via SuiteScript

Written by
Manuelito Macalinao
Published on
February 29, 2024 at 7:27:07 AM PST February 29, 2024 at 7:27:07 AM PSTth, February 29, 2024 at 7:27:07 AM PST
Scenario
Upon creating a CSV file based off a saved search via Script, the user encounters a blank cell and succeeding field values are then populated on the next line in which is caused by either a line break, Pipe, or illegal characters on either one of the fields. (i.e. memo/comment field)
Solution

The data from the field must first undergo this logic so that it can be formatted to fit through a single column each time a data is being passed and assigned to a column. This will avoid a next line placement for each line within the item description.

To do this, itfunctions that will eliminate said unwanted HTML character codes.

functionisEmpty(fldValue){return fldValue ==''|| fldValue ==null|| fldValue ==undefined;}functionnl2br(str, is_xhtml){var breakTag =(is_xhtml ||typeof is_xhtml ==='undefined')?'':'';return(str +'').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,'$1'+ breakTag +'$2');}