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

Pass the current patient into a medication-list screen, then filter the list through Adalo relationships instead of adding manual foreign-key text fields.

- 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-08-14
- Index status: index-now

## Short answer

Pass the Current Patient into the medication-list screen, then filter that screen’s list where Medication > Patient equals Current Patient. Model the Patient-to-Medication relationship in Adalo instead of adding manual foreign-key text fields, and keep the selected patient in screen context through the detail flow.

Let relationships carry identity through the flow: caregiver to patient, then patient to medications. Each screen should receive the selected record explicitly before its list applies a relationship filter.

## Intended outcome

A caregiver can select a patient, tap a button, and see only that patient’s related medications before opening medication details.

## 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.

## 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.

## 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.

## 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.
- [ ] 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

## 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.

## 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.

## 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)

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