Skip to main content
Liaison

Using Translation Tables to Export a Property that Varies Based on Question Response and Program

In your instance of Outcomes, you may have translation tables that convert the value in an application property to something else, making it work with your exports. If you have multiple programs with a similar question, these questions will be collected under different application properties. As a result, you may want to create a new field that collects all of these properties, runs them through a translation table, and then produces a final value based on what it finds.

In this article, you'll learn to create an exportable field that looks at various properties and applies the translation of your choice. For this to work, the following should already be in place:

  • Identify which application properties need to be considered for each program. For example, if the question you want to consider is "How did you learn about our program?", and each program has its own version of this question, you'll need to identify which property contains the answer to this question within each program.
  • Create translation tables to convert your values. For example, if you need to convert the applicant responses to a code, you'll need to add translation tables that map out what codes should be exported based on each possible response.

Once this is in place, this advanced configuration will help you create an application or export property that implements the needed translation and collects the final value in a single field.

Building the Custom Property

For this step, begin building a custom property using the Calculated property type. In the Expression window, paste the JavaScript code below. Then, you'll need to replace all of the variables in the code and duplicate the relevant snippet so that it will work in your environment. Alternatively, you can add this code directly into an export by selecting the Calculated option under Available Fields.

Add the JavaScript Code

Create a calculated custom property.  Add the following code into the Expression window. Hover over the window below and click the view source button at the top right to copy the code.

{
    let conditionField1 = yourfield1;
    let conditionField2 = yourfield2;

    if (program.name.includes("1")
         && conditionField1 != ""){
        
        return translate(conditionField1,'Translation Table 1')
        
    } else if (program.name.includes("2") && conditionField2 != ""){
        
        return translate(conditionField2,'Translation Table 2')
    }
  else {
            return '';
    }   
}

Next, you'll need to replace the variables in the code with fields that are relevant to your desired result.

Replacing the Variables

The variables included in the code snippet above are as follows:

  • let conditionField1 = yourfield1;  - here you'll replace yourfield1 with the name of the field that you are working with.
  • let conditionField2 = yourfield2;  - here you'll replace yourfield2 with the name of the field that you are working with.
  • if (program.name.includes("1") - here you'll replace 1 with the name of the program that relates to your first translation. E.g., if (program.name.includes("Online MBA").
  • return translate(conditionField1,'Translation Table 1') - here you'll replace Translation Table 1 with the name of the translation table that converts the value for this program appropriately.
  • else if (program.name.includes("2") && conditionField2 != "") - here you'll replace 2 with the name of the program that relates to your second translation.
  • return translate(conditionField2,'Translation Table 2') - here you'll replace Translation Table 2 with the name of the translation table that converts the value for this program appropriately.

Where needed, use the Field Dictionary to find the appropriate field names.

Next, where applicable, you'll need to add additional lines of code to account for more programs that you need to work with, as described below.

Adding Additional Lines of Code

As written, the sample code works in situations where there are only two programs that need to be considered. For each additional program, you'll need to:

  1. Add an additional let conditionFieldX line (e.g., let conditionfield3 = yourfield3;).
  2. Repeat the following else if portion of the code snippet found below.
  3. Update the applicable variables (e.g., update yourfield3 to the name of the third field you're considering,  update the 2 in program.name.includes("2") to the name of the program you're working with, and update the 3 in conditionField3 to the appropriate number).

else if (program.name.includes("2") && conditionField2 != ""){
        return translate(conditionField1,'Translation Table 1')
    }

Place this line of code before the else { line. Continue adding this snippet and updating its variables until you've accounted for all the programs that you want to work with this code.

Once complete, your code may look similar to the following:

Translation table advanced config example

Testing the Code

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.

Setting Up the Export

To include this custom property in an export, in the Available Fields area, find the custom property you created above and add it to the Columns window.

As an alternative, you could add a Calculated field in your export, and paste the code listed above into the Expression field.

 

  • Was this article helpful?