Skip to main content
Liaison

Remove Special Whitespace from Exports

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.

Setting Up the Export

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.

  • adding-calculated-property-to-export.png

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.

JavaScript Code

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);

}

Modify the Code

Once you've added this code into your JavaScript expression, you'll need to modify it in the following ways:

  1. Indicate which field you want to strip the whitespace characters from. Each form in the software has a key associated with it. Each field within each form also has a key. Find the key of the form you want to use, and update the let form = line, replacing program_questions_mba_online with that key.
    locating-all-eval-form-keys.png
  2. Find the key for the specific field you want to export. Use that to replace disciplined_explanation on the let field = line.
  3. Using the sample screenshot above, if you wanted to export the Recommend decision field and strip the special whitespace characters from it, the top of the Expression field would contain the following lines:
    let form = 'committee_review';
    let field = 'committee_decision';
  1. After modifying the JavaScript Expression, click Update. Continue adding fields as needed, and then run your Export.
    update-field-expression.png
  2. If there are other fields you need to remove whitespace from, continue adding Calculated Fields and repeat steps 1-4 as described above. Then run your export.

 

  • Was this article helpful?