# How do you open a patient’s related medications from a button in Adalo?

Pass a related parent record into one reusable detail screen, using a one-item list when an intermediate record cannot supply that parent directly.

- Canonical URL: https://adalocado.com/answers/open-related-medications-from-button
- Verification: Documented from current sources
- Topic: Lists, Filters, and Search
- Skill level: Beginner
- Last reviewed: 2026-09-06
- Index status: index-now

## Short answer

Pass the related parent record into the destination screen and filter its child list by that Current Parent. If an intermediate screen only has a child or join record, add a one-item list of parent records filtered to the related parent, then place the link inside that list so it can pass the correct record.

Let relationships carry identity through the flow. Pass the parent record directly whenever it is available. If an intermediate screen exposes only a related child or join record, filter a parent list to the related parent, keep that list to one result, and place the destination link inside the row so the required Current Parent reaches the reusable detail screen.

## Intended outcome

A user can move from a parent list or an intermediate related record into one reusable parent detail screen, then see only that parent's child records.

## Requirements

- Caregivers, Patients, and Medications collections
- A Patient-to-Medication relationship
- A Patient detail screen that has Current Patient available

## Step by step

1. **Model the relationships**

   Relate each Medication to one Patient, and relate Caregivers to the Patients they may access. Do not add duplicate text fields to imitate foreign keys.

2. **Open the current patient**

   From the caregiver’s patient list, link the selected list item to the Patient detail screen so Current Patient becomes available.

3. **Pass patient context from the button**

   Add a button on the Patient detail screen and link it to the medications screen while passing Current Patient.

4. **Filter the medication list**

   Set the medications list to Medications and filter where Medication > Patient equals Current Patient.

5. **Open medication details**

   Link each medication list item to its detail screen while passing Current Medication.

6. **Add a one-item parent list when context is missing**

   When an intermediate screen has Current Application but not Current Activity, add a list of Activities filtered so Activity ID equals Current Application > Activity > ID. Put the link button inside that list so the clicked row passes Current Activity to the existing Activity detail screen.

## Why it works

- Adalo screen context carries the selected record between screens, while relationships express which medications belong to that patient.
- Manual foreign-key text fields duplicate relationship state and make filters harder to maintain.
- A component can pass the Current record supplied by its list row, so a list filtered to one related parent can restore missing parent context without creating a second detail screen.

## Data model

| Collection | Properties | Relationships |
| --- | --- | --- |
| Patients | Patient details | Many Medications; connected to permitted Caregivers |
| Medications | Medication details | Belongs to one Patient |
| Caregivers | User profile fields | Related to permitted Patients |

## Common failures

### Current Patient is unavailable

Check that the previous list item or button links to the screen with the selected Patient record rather than navigating without data.

### Every medication appears

Add the Patient relationship filter to the medications list and compare it to Current Patient, not Logged-in User.

### The link menu offers only the intermediate record

Create a one-item list of the required parent collection, filter it to the intermediate record's related parent ID, and place the destination link inside that list.

## Testing checklist

- [ ] Open two patients with different medications and confirm each screen shows only its own records.
- [ ] Open a patient with no medications and confirm the screen presents an intentional empty state.
- [ ] Open two intermediate records related to different parents and confirm the one-item list passes the matching parent each time.
- [ ] Each Medication relates to one Patient
- [ ] The patient list passes Current Patient
- [ ] The button preserves Current Patient
- [ ] The medication list is relationship-filtered
- [ ] Medication details receive Current Medication
- [ ] A one-item fallback list returns exactly the related parent when direct screen data is unavailable

## Limitations

- Current Adalo documentation corroborates record relationships, link actions, and list filtering, but the source thread does not provide a complete current-builder reproduction of this patient workflow.
- Authorization must still restrict which patients a caregiver can access; a list filter alone is not a security boundary.
- The one-item-list fallback is necessary only when the required parent is missing from Available Screen Data. Prefer a direct link when the parent record is already available.

## Community evidence

### [Accessing a simple list from a button](https://forum.adalo.com/t/accessing-a-simple-list-from-a-button/65617/9)

The solved thread confirms a working sequence from caregiver patients to patient details, patient medications, and medication details using Adalo record context. Boundary: The accepted post reports the result but does not document every current editor control or authorization rule.

### [Link action doesn't send data from a database with a relationship](https://forum.adalo.com/t/link-action-doesnt-send-data-from-a-database-with-a-relationship/55821)

The accepted answer explains how a one-item Activities list filtered through Current Application restores Current Activity and lets the existing Activity detail screen receive the correct record. Boundary: The thread demonstrates the pattern with Activities and Applications, so collection names and relationship paths must be adapted to the app's data model.

## Sources

- [Adalo forum accepted solution](https://forum.adalo.com/t/accessing-a-simple-list-from-a-button/65617/9)
- [Adalo Help: Relationships](https://help.adalo.com/database/relationships)
- [Adalo Help: Links](https://help.adalo.com/actions/links)
- [Adalo Help: Lists](https://help.adalo.com/component-basics/connecting-lists-and-forms-to-a-database)
- [Adalo forum: related record link solution](https://forum.adalo.com/t/link-action-doesnt-send-data-from-a-database-with-a-relationship/55821)
- [Adalo Help: Filtering in Adalo](https://help.adalo.com/component-basics/conditions-and-filtering/filtering-in-adalo)

Markdown version: https://adalocado.com/answers/open-related-medications-from-button.md
