By default, when you include test scores in an export or the Application Summary, Outcomes displays all instances of that test. If you're more interested in collecting just one test date, you can use a JavaScript expression to isolate that value.
In this article, you'll learn to apply JavaScript to a custom property or an export field that allows you to distill multiple test scores into one value. This can be used in connection with ACTs, GMATs, MCATs, SATs, or other tests that can have multiple values.
You have two options when adding the JavaScript Code for this configuration:
In either case, you'll have an Expression area to add your code and configure it as desired.
In the Expression area, add the following code. This snippet results in one field that displays a date value as described above. (Use the view source icon at the top right to copy the code snippet.)
{
let formName = "formName";
let testName = "testName";
let testField = "testField";
let dateField = "dateField";
let index = 0;
if (forms?.[formName]?.[testName]?.rows?.length > 0) {
if (forms?.[formName]?.[testName]?.rows[index]?.[dateField] != null) {
var date = new Date(forms?.[formName]?.[testName]?.rows[index]?.[dateField]);
var yr = date.getFullYear();
var mon = date.getMonth() + 1;
mon = (mon.toString().length == 1) ? '0' + mon : mon;
var day = date.getDate();
day = (day.toString().length == 1) ? '0' + day : day;
dateFormatted = (date) ? yr + '/' + mon + '/' + day : "";
return dateFormatted;
}
}
else {
return "";
}
}
After dropping in this code, you'll need to update the variables so that it will work with the test of your choice. Review the guidance below for more details.
For this expression to work in your environment, you'll need to replace the variables at the top of the code snippet. By updating the variables listed below, you'll indicate which test's date you'd like to extract.
For more details, review Finding the Keys to Use.
The test scores you need are typically stored in an applicant form. Within the form, the details of each test, including scores, dates, and other relevant information, might be captured in a table. Review the steps below to modify the code to work with tests that are stored in a table.


Using the example above, the editable area of the code would appear as follows:
let formName = "gradesScores";
let testName = "satoptional";
let testField = "satEvidenceBasedReadingAndWriting";
let dateField = "satExamDate";
let index = 0;
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-7.