--- title: "How to Validate Reference Fields on the Enrollment Record" slug: "how-to-validate-reference-fields-on-the-enrollment-record" description: "Provides a java script expression that verifies cross-record references on enrollment records exist before including the enrollment record in the output for the consuming application. " tags: ["Administrator", "Studio", "Field Mapping", "Filters"] updated: 2023-02-09T23:58:50Z published: 2023-02-09T23:58:50Z canonical: "help.rapididentity.com/how-to-validate-reference-fields-on-the-enrollment-record" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.rapididentity.com/llms.txt > Use this file to discover all available pages before exploring further. # How to Validate Reference Fields on the Enrollment Record ## Validate that Cross Field References on Enrollments Exist 1. Open the Consumer Application in Studio and go to the **Advanced** Menu 2. Find the application's **Enrollment** Record Mapping, then click the kabob menu and select **Details** 3. Scroll down to the Field Mappings and check to see that there isn't already a mapping for **Target Field Name** of **recordStatus** for the **Create, Update** events. **Note:** **recordStatus** mappings on **Create, Update** events are a quick and easy way to **filter out** records that do not meet specific criteria that's defined in the mapping expression. 1. Click the **ADD** button to create a new **Field Mapping** 2. Set the **Target Field Name** to **recordStatus** 3. Set the **Value Type** to **Expression** 4. Keep the **On Create** and **On Update** checkboxes checked 5. Paste the following code into the **Value** input area: ``` function() { const userKey = SRC.user[0]; const classKey = SRC.section[0]; const orgKey = SRC.org[0]; var enrollmentUser = SRC.getRecord("user",userKey); var enrollmentClass = SRC.getRecord("section",classKey); var enrollmentOrg = SRC.getRecord("org",orgKey); var error = 'no'; if (!enrollmentUser) { LOGGER.warn("unable to find user record with recordKey " + userKey + " in enrollment " + SRC.recordKey); error = 'yes'; } if (!enrollmentClass) { LOGGER.warn("unable to find class record with recordKey " + classKey + " in enrollment " + SRC.recordKey); error = 'yes'; } if (!enrollmentOrg) { LOGGER.warn("unable to find org record with recordKey " + orgKey + " in enrollment " + SRC.recordKey); error = 'yes'; } if (error == 'yes') { LOGGER.warn("skipping enrollment record with recordKey " + SRC.recordKey); return 'delete'; } return null; } ``` 6. Click Save 7. The next time the **Enrollment** mapping job is run for the consumer, check in the **Data Explorer** for the **Consumer Application -enrollment** records to verify the expected outcome from this mapping function. *This expression, when mapped to the **recordStatus** on **Create** and **Update** events on a consumer application, verifies that the **User**, **Class** and **Org** references on each enrollment record exist in the **ID Hub** else, the record is not included in the output for the consumer application.* ## Related - [Verification of OneRoster REST Consumer on the Studio Tenant](/verification-of-oneroster-rest-consumer-on-the-studio-tenant.md) - [Excluding Unneeded Files from Application Templates](/excluding-unneeded-files-from-studio.md) - [How to Change Username values on the User Record](/how-to-change-username-values-on-the-user-record.md)