Unify Responses from Different Questions to Appear in a Single Field
If you've created custom program-level questions for your applicants, there may be some instances where separate questions are used to collect the same information. For example, you may have several programs where you ask the applicants about their desired start term. Since you're using program-level questions, the responses are stored in separate fields. This configuration allows you to combine responses to these custom questions into a single field in Outcomes.
In the screenshot below, the exported file displays several custom questions, each from a different program. These custom questions all contain the applicants' desired entry terms. Without this configuration, each custom question needs to be exported separately to display this data. In this example, the Combined Field captures the data from all related custom questions and consolidates the responses to a single field. Unifying these responses eliminates the need to export each custom question, and also makes it easier to filter and sort this information from within Outcomes.
This article explains how to:
- build the Custom Property to unify these fields.
- use the Custom Property in filters and exports.
Building the Custom Property
To build the Custom Property that combines these separate custom questions fields, you'll need to:
- Identify which fields you'd like to consolidate.
- Evaluate the field names to find a common string of characters that they all have. Your JavaScript expression will use this string of characters to determine which fields should be consolidated.
- Create a Custom Property using the included JavaScript expression.
- Update the JavaScript expression to include the common string of characters that you've selected.
Select Your String
First, you'll need to determine which fields you'd like to unify, and what string of characters from their field names can be used to identify them. The JavaScript expression will use this string of characters as it automatically selects which fields should be consolidated into your combined field.
To begin, you may wish to consult the Field Dictionary. This is a tool that allows you to find information about the fields available to work with in Outcomes. For example, if you'd like to combine the desired entry term field across several programs, you can search the Field Dictionary to identify what the field names look like.
In the example above, each of the fields contains the text cq_please_select_your_desired_entry_term_XXXXXXXXXX. So, a common string of characters is please_select_your_desired. If you use that string in your JavaScript expression, this configuration will locate all fields with please_select_your_desired in their field name, and unify those responses into one field. Be careful not to be too indistinct with the string you select (e.g., cq_please), as that could result in unwanted fields being included.
Build the Custom Property
Next, create a new Custom Property using the Calculated Property option. Set the Data Type as String. In the Expression area, paste the following JavaScript code. Click the view source icon at the top right to copy the code snippet.
{ // This is the partial question property string to match on when scanning custom forms let qString = "cq_partial_name_of_custom_question"; // This is the value that will be returned if no answer is found. let defaultResponse = ''; // NOTE: Function below does not need to be updated let returnArray = Object.keys(forms) .filter((formName) => { return formName.includes('cas') || formName.includes('ps') ; }) .map((formName) => { let localqs = Object.getOwnPropertyNames(forms[formName]).filter(function(prop) { return prop.includes(qString) }); return forms[formName][localqs] }) .filter((formResponses) => { return formResponses != null; }); return returnArray.length? returnArray[0] : defaultResponse; }
The resulting field will look like this:
Modify the Code
Next, you'll need to modify the code so that your new Custom Property will identify which fields it should combine. To do this, find the let qString = line of code and replace "cq_partial_name_of_custom_question" with the string that you selected earlier. In the example above "cq_please_select_your_desired" was used. To ensure the field is working correctly, you may use the Try it feature to test the expression with your current applications.
Click Add to save your new Custom Property. This property will scan your fields to find any that include the string you selected in their field name.
Using the Custom Property in Exports
Now that you've built your Custom Property, you can include it in Exports.
As an alternative to the instruction described above, if you only need to export this field, and won't need to use it anywhere else in Outcomes, you may also use this configuration to add a Calculated Property to an Export. The JavaScript Expression will work the same way, consolidating the fields that it finds.
Using the Custom Property in Other Areas
Once you've built the Custom Property using this configuration, you can also use it in other areas. For example, you can:
- Use the Custom Property to filter your applications.
- Use the Custom Property as a column heading.
- Use the Custom Property in your Application Summary.