[{"data":1,"prerenderedAt":20},["ShallowReactive",2],{"blog-post-en-build-reusable-broma-subflows-for-team-form-filling":3},{"slug":4,"lang":5,"title":6,"summary":7,"date":8,"tags":9,"tag_slugs":15,"thumbnail_url":16,"translations":17,"body":18,"asset_base":19},"build-reusable-broma-subflows-for-team-form-filling","en","Build Reusable Broma Sub-Flows for Team Form Filling","Learn how to create modular sub-flows in Broma that your whole team can reuse for consistent form filling across multiple sites.","2026-11-08",[10,11,12,13,14],"broma","automation","team-workflows","form-filling","subflows",[10,11,12,13,14],"https:\u002F\u002Fblog-api.bromaapp.com\u002Fapi\u002Fblog\u002Fposts\u002Fbuild-reusable-broma-subflows-for-team-form-filling\u002Fthumbnail.svg?lang=en",[5],"## Why reusable sub‑flows matter\nWhen several people automate the same web forms — checkout, signup, profile updates — copying steps into every flow creates maintenance nightmares. A single selector change forces you to edit dozens of flows. Sub‑flows solve this by letting you define a form‑filling routine once and call it from any parent flow.\n\n## What a sub‑flow is in Broma\nA sub‑flow is a regular Broma flow that exposes input parameters. Other flows invoke it with the **Call Flow** step, passing values at runtime. Because the sub‑flow runs in the same browser profile, it inherits cookies, logins, and proxy settings automatically.\n\n## Benefits for a team\n- **Consistency** – every flow uses the exact same field order, validation, and error handling.\n- **Single source of truth** – fix a selector once; all callers benefit.\n- **Faster onboarding** – new members drop a Call Flow step instead of rebuilding the form logic.\n- **Version control** – export the sub‑flow JSON, store it in Git, and review changes like code.\n\n## Step‑by‑step: build an address sub‑flow\n### 1. List the common fields\nTypical address forms share these fields:\n- Full name\n- Street line 1\n- Street line 2 (optional)\n- City\n- State \u002F province\n- Postal code\n- Country dropdown\n- Phone number\n\n### 2. Create a new flow and add parameters\n1. In Broma, click **New Flow** → name it `Subflow_AddressForm`.\n2. Open the **Variables** panel and add the following **Input** variables (type *Text* unless noted):\n   - `fullName`\n   - `street1`\n   - `street2`\n   - `city`\n   - `state`\n   - `postalCode`\n   - `country` (type *Text*; you’ll map to the dropdown value)\n   - `phone`\n\n### 3. Add steps with resilient selectors\nUse the **Select Element** tool to pick each input. Prefer attributes that rarely change: `name`, `data-testid`, or `aria-label`. Example for the street line:\n```json\n{\n  \"selector\": \"input[name='address_line1']\",\n  \"action\": \"type\",\n  \"value\": \"{{street1}}\"\n}\n```\nRepeat for each field. For the country dropdown, use a **Select Option** step with `value: \"{{country}}\"`.\n\n### 4. Clean and format data with JavaScript expressions\nPhone numbers often arrive in various formats. Add a **Run JavaScript** step before typing the phone field:\n```javascript\n\u002F\u002F Normalize to digits only, then format as +1 (555) 123-4567\nconst raw = {{phone}};\nconst digits = raw.replace(\u002F\\D\u002Fg, '');\nif (digits.length === 10) {\n  return `+1 (${digits.slice(0,3)}) ${digits.slice(3,6)}-${digits.slice(6)}`;\n}\nreturn raw; \u002F\u002F fallback\n```\nAssign the result to a temporary variable `cleanPhone` and type `{{cleanPhone}}` into the phone input.\n\n### 5. Test the sub‑flow in isolation\n1. Open a test page that contains the address form (e.g., a staging checkout).\n2. Run the flow with sample values in the **Run Flow** dialog.\n3. Verify each field is filled correctly and the form submits without errors.\n\n## Calling the sub‑flow from parent flows\n### 1. Add a Call Flow step\nIn any parent flow (e.g., `Checkout_Guest`, `Signup_Newsletter`), insert a **Call Flow** step.\n- **Flow to call**: `Subflow_AddressForm`\n- **Parameter mapping**:\n  ```json\n  {\n    \"fullName\": \"{{customer.name}}\",\n    \"street1\": \"{{customer.address.line1}}\",\n    \"street2\": \"{{customer.address.line2}}\",\n    \"city\": \"{{customer.address.city}}\",\n    \"state\": \"{{customer.address.state}}\",\n    \"postalCode\": \"{{customer.address.zip}}\",\n    \"country\": \"{{customer.address.countryCode}}\",\n    \"phone\": \"{{customer.phone}}\"\n  }\n  ```\n\n### 2. Pass data from CSV, API, or previous steps\nIf you batch‑process orders, loop over a CSV file and feed each row into the Call Flow step. The sub‑flow receives the exact values it expects.\n\n## Version control and sharing\n1. **Export** the sub‑flow: right‑click → **Export Flow** → save as `Subflow_AddressForm.json`.\n2. Commit the JSON to your team’s Git repo. Include a `README.md` that documents each input variable and expected format.\n3. When a selector changes, update the sub‑flow, commit, and ask teammates to pull the latest version.\n\n## Example: one sub‑flow, three parent flows\n| Parent flow | Use case | How it calls the sub‑flow |\n|-------------|----------|---------------------------|\n| `Checkout_Guest` | Guest checkout on Shopify | Maps order‑summary variables to address fields |\n| `Signup_Newsletter` | Newsletter signup with optional address | Passes only `fullName`, `email`, `country`; leaves address lines empty |\n| `Profile_Update` | User edits saved address | Reads current profile data, sends to sub‑flow, then clicks **Save** |\n\nAll three flows stay in sync because they share the same sub‑flow logic.\n\n## Common pitfalls and fixes\n- **Parameter name mismatch** – Broma validates at runtime; double‑check spelling in the Call Flow mapping.\n- **Selector drift** – If a site redesigns the form, update the selector in the sub‑flow once; all callers inherit the fix.\n- **Optional fields** – For fields like `street2`, guard the type step with a **Branch** step: `if ({{street2}} !== \"\") { type … }`.\n- **Dropdown value vs. label** – Ensure the `country` variable matches the dropdown’s `value` attribute, not the visible label.\n\n## Best‑practice checklist\n- [ ] Name sub‑flows with a `Subflow_` prefix for easy discovery.\n- [ ] Document every input variable (type, example, required\u002Foptional).\n- [ ] Keep selectors anchored to stable attributes (`name`, `data-testid`).\n- [ ] Use JavaScript expressions for data cleaning, not multiple type steps.\n- [ ] Export and commit after every change; tag releases (e.g., `v1.2.0`).\n- [ ] Run a quick smoke test on a staging environment before merging.\n\n## Wrap up\nReusable sub‑flows turn repetitive form‑filling into a maintainable library. By defining the address logic once, exposing clear parameters, and calling it from any parent flow, your team reduces errors, speeds up new automations, and keeps all workflows aligned when a site changes. Start with a single high‑frequency form, promote it to a sub‑flow, and watch the maintenance burden drop across every project that touches that form.\n","https:\u002F\u002Fblog-api.bromaapp.com\u002Fapi\u002Fblog\u002Fposts\u002Fbuild-reusable-broma-subflows-for-team-form-filling\u002Fassets",1794729621416]