Store the Most Recent Child Value Using Record Actions and Mapping Fields
Learn how to store the most recent child record value on a parent record in Knack using mapping fields and a record action, so the value can drive emails, filters, and other logic.
What You'll Learn
This article shows how to store the most recent child record value on a parent record using mapping fields and a record action. This is the approach to use when the value needs to drive downstream logic like email rules, filters, conditions, or reports.
If you just need to display the value without using it for logic, see Display the Most Recent Child Record in a Filtered Modal or Display Connected Child Records on a Parent Details Page.
How It Works
You add fields to the parent table that mirror the child field types. These are called mapping fields. Then you configure a record action on the child form that updates the connected parent record when a new child record is submitted. The record action copies the child's field values into the parent's mapping fields.
Once set up, the parent record always holds the most recent child values as real data. You can reference those fields in email rules, filters, conditions, and reports just like any other field.
Example Scenario
You have a Contacts table and an Interactions table. Each Contact has many Interactions. You want to store the date and outcome of the most recent Interaction on the Contact record so you can:
- Filter Contacts by "last interaction in the past 30 days"
- Send an email that references the last interaction date
- Run a report grouped by last outcome
Steps
1. Add Mapping Fields to the Parent Table
On the parent table (Contacts), add fields that mirror the child fields you want to store. Match the field types exactly.
For this example, add:
- Last Interaction Date (Date/Time field, matching the Interaction's date field)
- Last Interaction Outcome (Multiple Choice field, matching the options of the Interaction's outcome field)
Match field types carefullyIf the child field is Multiple Choice, the parent mapping field must be Multiple Choice with the same options. If the child field is a Date/Time, the parent must be a Date/Time. Mismatched types will cause the record action to fail silently.
2. Open the Child Form's Record Actions
Navigate to the page containing the child form (the form where users add new Interactions).
Click the Form Element to select it. The right panel switches to Form Settings.
In Form Settings, click Record Actions. The description reads "Automatically update or insert records after the form is submitted."
3. Add a Record Action
Click + Action to open the Add Record Action modal.
Configure the action:
- On Submission: select Update connected records
- Connection: select the connection to the parent table (for this example, the Contact connected to this Interaction record)
- In Update Field Values, map each parent mapping field to the matching value from the submitted child record. For each row, select the parent field on the left, change the value-type dropdown to to a field value, then select the matching child field on the right:
- Last Interaction Date
to a field value→ Interaction Date - Last Interaction Outcome
to a field value→ Outcome
- Last Interaction Date
Click + to add additional field mappings as needed.
Leave the Conditions section set to "This action will run on every form submission" unless you want to restrict when the action fires.
Click Add Action to save.
4. Test the Setup
In the Live App, submit a new Interaction record for a Contact. Open that Contact's record and confirm the Last Interaction Date and Last Interaction Outcome fields now show the values from the Interaction you just submitted.
Submit a second, newer Interaction for the same Contact. Confirm the Contact's mapping fields updated to the newer values.
Where Record Actions Should Live
Record Actions are configured on a specific Form Element. Each form on a page is its own element with its own settings. That means an Add form and an Edit form for the same table have separate Record Action configurations.
This matters because it determines when the parent's mapping fields get updated. Choose based on your use case.
Configure on Add Form Only
The record action fires only when a new child record is created. Editing an older child record will not update the parent.
Use this when:
- You want "most recent" to mean "most recently created"
- You do not want edits to older records to overwrite the parent's values
- New entries are the only thing that should push to the parent
Configure on Both Add and Edit Forms
The record action fires whenever a child record is created or edited. Every edit pushes the current child values to the parent.
Use this when:
- The parent should always reflect the latest state of any child record, including edits
- Users commonly correct or update existing child records and want those changes reflected
- "Most recent" means "most recently touched" rather than "most recently created"
Choose based on your workflowNeither setup is wrong. Think through how users work with child records. If they mostly add new ones and rarely edit, Add-only keeps things predictable. If they regularly edit existing records and want those edits reflected on the parent, Add and Edit makes sense.
Optional: Add a Toggle to Control When Updates Run
If you want finer control over when the record action fires, add a yes/no field to the child table and reference it in the record action's Conditions. For example, on Add and Edit forms you might only want certain edits to push to the parent.
- Add a yes/no field to the child table (Interactions) called Update parent record with a default of No.
- In the record action, go to the Conditions section and click + Condition.
- Set the condition to run only when
Update parent record is Yes.
When a user adds or edits a child record and wants it to push to the parent, they toggle the field to Yes before saving. For everything else, the parent stays untouched.
Common Mistakes
- Mismatched field types between the child and parent mapping field. The record action will not populate.
- Not thinking through which forms the record action should live on. Add-only and Add+Edit behave differently and the right choice depends on your workflow.
- Forgetting that this approach only fires when records are submitted through the configured form. Records added via import or API will not trigger the record action.
Next Steps
- Display Connected Child Records on a Parent Details Page to pair the stored values with the full history.
- Display the Most Recent Child Record in a Filtered Modal if you only need to show the most recent record, not store it.
- Display the Most Recent Child Record Value on a Parent Record for an overview of all three approaches and how to choose.
Updated 4 days ago
