This recipe describes how you can dynamically launch non-interactive flows from a button click in Community Hub fully through point and click.
In this example we will create a button to launch a flow. This flow will alter an Account record(s) returned by a Query, adjusting the last name field, and updating the record(s) in the database.
To do this, follow the below steps:
Create a Query Record
This query (See: creating a query) will return the current Account that clicks the button. The resulting record(s) from this query will be used as an input variable for our flow.
Create a Data Source
Create a data source which uses the query created above. Enter the below values when creating the Data Source:
-
In Class, enter
NC.SOQLDataSource. -
In Context, enter the Query Name of the query created before.
Create a Flow
Our simple example is a flow that alters the record(s) returned by the Query record, adjusts the last name, and updates them in the database. This is a simple example, but our hope is you can see additional possibilities.
Follow the below steps:
-
From Setup, enter
Flowsin the Quick Find box, then select Flows -
Click New Flow.
-
Select
Screen Flowand click Create. -
From the dropdown on top ribbon, select
Freeform. -
From the Manager tab in left navigation, click New Resource.
-
Enter the API Name as
Account_ids. -
Enter a description.
-
In Data Type, select
Number. -
Select Allow multiple values (collection).
-
Select Available for input.
-
Click Done.
-
From left navigation menu, drag and drop
Loop.
Create a New Button
Create a button to launch the flow created above, specifying the following:
-
The
NC.DynamicFlowButtonclass. -
The name of the Data Source we created.
-
The name of our flow.
When the button is rendered in Community Hub and a user clicks it, the following happens:
-
The query record in the data source is run, returning records to the button.
-
The button passes in these records to the flow as input variables.
-
The flow runs and updates the Account fields.
-
The button completes the run cycle as usual, reloading the existing page, or going to another page depending on configuration.
-
Any list of records which can be returned from a Query record can be pushed into the flow as an SObject collection.
-
When specifying a FinishURL output variable in the flow, it must begin with a "/" . E.g., /personalsnapshot instead of personalsnapshot.