# How can screen flows be utilized to build custom guided selling flows directly on opportunity pages?

**Topic:** Sales Cloud · **Difficulty:** Medium · **Tags:** Sales Cloud, Guided Selling, Screen Flows

Read it on the site: https://www.forcechallenges.com/interview-questions/how-can-screen-flows-be-utilized-to-build-custom-guided-selling-flows-directly-on-opportunity-pages

## Answer

**Basics:** A screen flow shows a series of screens and runs logic between them. Embedding it on an Opportunity guides reps through qualification questions, product selection and required fields, replacing long, error-prone page layouts.

**How it works:**
1. Create a screen flow with a text input variable named recordId (Available for input).
2. Get Records for the Opportunity, show Screens (Dynamic Choice picklists, Data Table for products, conditional visibility, reactive components), then Create/Update Records.
3. In Lightning App Builder, drag the Flow component onto the Opportunity page, select the flow and map recordId to {!recordId}.
4. Or create a Flow quick action, or place the flow in a modal from a button.
5. Set Finish behavior (show a message, navigate with a Navigation element, refresh).

**Advanced / deep dive:** Use subflows for reuse, validation with screen-level conditions, and fault paths. Use Opportunity Path with key fields and guidance in parallel for stage-based coaching. For product configuration, loop through selected products and build a collection, then do a single Create Records outside the loop to stay bulk-safe. Flow runs in user context by default for screen flows launched from the UI, so FLS and sharing apply; you can change it in flow settings (system context with or without sharing). Each screen starts a new transaction, so limits reset between screens. A flow interview can execute at most 2,000 elements at runtime.

**Code / config example:** Launch the flow from LWC:
```html
<template>
    <lightning-flow flow-api-name="Opportunity_Guided_Selling"
                    flow-input-variables={inputs}
                    onstatuschange={handleStatus}></lightning-flow>
</template>
```
```javascript
import { LightningElement, api } from 'lwc';
export default class GuidedSellingHost extends LightningElement {
    @api recordId;
    get inputs() { return [{ name: 'recordId', type: 'String', value: this.recordId }]; }
    handleStatus(e) { if (e.detail.status === 'FINISHED') { /* refresh / toast */ } }
}
```

**Hidden gotchas & must-remember points:**
- The variable must be named exactly recordId (case-sensitive) to receive the record context automatically.
- Users need Run Flows permission or flow access through profile or permission set.
- Inactive flows cannot be launched; save a new version and activate it.
- Required fields in screens do not enforce object validation until the DML executes.
- Flow does not support if-in-loop DML safely; collect then commit.
- Process Builder and Workflow Rules are retired in favor of Flow.

**Best practice:** Keep screens short, validate early, and log faults so reps are never stuck on a failed screen.

---
Source: ForceChallenges · last updated 2026-11-02
