Skip to main content

Flow Wiring

Every Screen Flow that uses a Keelstone LWC component must receive KeelstoneSessionId as a flow input variable and pass it to each component. Keelstone injects this value automatically when launching the flow — you only need to declare it and wire it.

1. Add the flow variable

In your flow's XML, add this variable declaration:

<variables>
<name>KeelstoneSessionId</name>
<dataType>String</dataType>
<isCollection>false</isCollection>
<isInput>true</isInput>
<isOutput>false</isOutput>
</variables>

In Flow Builder: Manager tab → New Resource → Variable, type String, input only.

2. Wire it to each component

For every Keelstone LWC on a screen, add an input parameter:

<fields>
<name>cmpMyComponent</name>
<extensionName>kstone:myComponent</extensionName>
<fieldType>ComponentInstance</fieldType>
<inputParameters>
<name>keelstoneSessionId</name>
<value><elementReference>KeelstoneSessionId</elementReference></value>
</inputParameters>
<isRequired>true</isRequired>
</fields>

In Flow Builder: select the component on the screen, find Keelstone Session ID in its properties, and set the source to the KeelstoneSessionId variable.

3. Re-declare in your LWC

Salesforce flow wiring only populates @api properties declared on the component class itself. Inherited properties are not wired. Add this to every component that extends a Keelstone class:

import { KSExcel } from 'kstone/api';
import { api } from 'lwc';

export default class MyComponent extends KSExcel {
@api keelstoneSessionId; // required — flow wiring won't work without this
}

And expose it in .js-meta.xml:

<targetConfigs>
<targetConfig targets="lightning__FlowScreen">
<property name="keelstoneSessionId" type="String" label="Keelstone Session ID" />
<!-- your other properties -->
</targetConfig>
</targetConfigs>

Quick-action flows (record context)

Flows launched from a Salesforce Quick Action on a record page also receive recordId as a separate input. Both variables are required:

<variables>
<name>recordId</name>
<dataType>String</dataType>
<isCollection>false</isCollection>
<isInput>true</isInput>
<isOutput>false</isOutput>
</variables>

<variables>
<name>KeelstoneSessionId</name>
<dataType>String</dataType>
<isCollection>false</isCollection>
<isInput>true</isInput>
<isOutput>false</isOutput>
</variables>

Sample flows

The keelstone/samples repo contains three fully-wired flows you can deploy and reference:

FlowComponentsPattern
Keelstone_Query_BuilderqueryBuilderLwcSOQL query → push results to Excel
CLM_Insert_Clause_FlowclauseLibrary, contractSearchBrowse clause library → insert into Word at cursor
KS_Account_Generate_Report(none — server-side only)Quick Action generates Excel from a template, no taskpane required

Query Builder and Clause Library both extend KSExcel / LightningElement and follow the standard KeelstoneSessionId wiring pattern described above.

Account Report uses only invocable Apex actions (kstone__KS_GetAccountReportContext, kstone__KS_GenerateDocument) — no LWC components, no KeelstoneSessionId needed. It is the pattern to use when document generation should happen entirely server-side from a record page button.