When you import applicant names from Outcomes into another system, there may be compatibility issues due to special characters, accent marks, excessive length, whitespace variations, or other unsupported formatting. From this article, you'll learn how to use JavaScript expressions in your exports to modify names in your exports as follows:
To accomplish these things, you'll combine various code snippets to achieve the desired output.
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 clicking the function icon and dropping the code listed below into the Expression field.
Then, update the code to indicate which field you are exporting.
While following the steps above, use the following code in your JavaScript Expression:
{
let name = enter?.fieldname?.here ? enter?.fieldname?.here : '';
// Strip special characters
name = name.replace(/\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\_|\+|\'|\ʻ|\=|\:|\;|\<|\>|\?|\,|\.|\"|\|/g,"");
// Make text proper case and remove extra whitespace
function proper_case(str) {
let sentence = str.toLowerCase();
let separator = "";
if (sentence.search(" ") > -1) {
separator = " ";
sentence = sentence.split(separator);
sentence = sentence.filter(function (el) { return (el || el.length > 0); });
} else if (sentence.search("-") > -1) {
separator = "-";
sentence = sentence.split(separator);
sentence = sentence.filter(function (el) { return (el || el.length > 0); });
} else {
sentence = sentence;
}
if (separator === "") {
sentence = sentence.charAt(0).toUpperCase() + sentence.substr(1).toLowerCase();
} else {
for (let i = 0; i < sentence.length; i++) {
sentence[i] = sentence[i][0].toUpperCase() + sentence[i].substr(1).toLowerCase();
}
sentence = sentence.join(separator);
}
return sentence;
}
name = proper_case(name);
function replaceAccents(field) {
try {
if (field == null || typeof field == "undefined") {
return "";
}
} catch (e) {
return "";
}
// Replace accented characters
let noAccents = field.normalize("NFD").replace(/[\u0300-\u036f]/g, "")
.replace(/[ø]/g, "o")
.replace(/[Ø]/g, "O")
.replace(/[æ]/g, "ae")
.replace(/[Æ]/g, "Ae")
.replace(/[ə]/g, "e")
.replace(/[Œ]/g, "Oe")
.replace(/[œ]/g, "oe")
.replace(/[ß]/g, "ss")
.replace(/[§]/g, "S")
.replace(/[łı]/g, "l")
.replace(/[đ]/g, "d")
.replace(/[Đ]/g, "D")
.replace(/[þ]/g, "p");
return noAccents;
}
name = replaceAccents(name);
// Set character limit
return name.substring(0, 60);
}
Once you've added this code to your JavaScript expression, you'll need to modify it. To do so:
While building the export or your calculated property, click the Try It button to confirm that your variables are working.
Search for a record to complete your tests with. Confirm that the appropriate value appears in the Output window.
This article corresponds with JSO-163.