When importing data into another system, you may need to remove special whitespace characters to make the file compatible. Whitespace characters are those that denote empty space between characters you need to see. These include tabs, carriage returns, line feeds, and excess spaces. The JavaScript configuration below allows you to strip these characters, leaving you with a usable export file.
To complete this configuration, you'll need to add a Calculated Field to a Tabular/Spreadsheet Export. You can do this while configuring your Export by dragging a Calculated Field into the Columns to export.
After dropping in the Calculated Field, use the JavaScript Expressions option by dropping the code listed below into the Expression field. Then, update the code to indicate which field you are exporting.
After following the steps above, use the following code in your JavaScript Expression:
{ /* * * * * * * * * * * * * * * USER INPUT SECTION * * * * * * * * * * * * * * */ // use this field to designate the key of the desired form let form = 'program_questions_mba_online'; // use this field to add the key of the desired field let field = 'disciplined_explanation'; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * DO NOT EDIT BELOW * * * NOTE: This function takes two inputs and return a single question response from the * Outcomes Application Data Object. This response is modified to remove any excess white space * (example: tabs, line breaks, carriage returns, excess spaces, line feed) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ function removeSpecialChar(formID, fieldID) { if ((forms) && (forms[formID]) && (forms[formID][fieldID])) { let string = forms[formID][fieldID]; //remove line breaks let noBreaks = string.replace(/(\r\n|\n|\r)/gm, " "); // remove tabs and excess spaces let noTabs = noBreaks.replace(/\s\s+/g, " "); return noTabs; } else { return; } } return removeSpecialChar(form, field); }
Once you've added this code into your JavaScript expression, you'll need to modify it in the following ways:
let form = 'committee_review'; let field = 'committee_decision';