LWC Flow Record Form - swift-ben/flowLWCDev GitHub Wiki

Flow Record Form

A LWC leveraging lightning-record-edit-form and lightning-layout to expose record edit/create forms to visual flow. Admins can define what fields to display and users have the ability to add additional rows to create new records or flag existing records for deletion. Admins can choose whether or not to allow users to add new rows or to delete existing records.

The instantiated/edited/deleted records are then passed back into the flow where they can be created, updated or deleted (the LWC itself does not create, update or delete records).

Demo here

This is a work in progress, so please let me know if you run across any bugs or have ideas for improvement by logging an issue.

Configuration Instructions

  1. Install the unmanaged package in Production or a Sandbox.
  2. Review the components in the provided Sample Flow
    • If you want to use the Sample Flow in Production, add some filters on Get Accounts and Get Contacts to avoid attempting to query all Records
  3. To configure the LWC
    1. Add a Screen Component to a flow
    2. Drag the Flow Record Form LWC into the Screen
    3. Wait for the config to load
    4. Hide the screen footer
    5. Use "Record Collection" to select the collection of SObject Records from your flow to edit/insert
      • To let users edit existing records and create new ones, use records from a Record Lookup Element
      • To only let users create new records, use an empty collection variable
    6. To prevent users from adding new records, check "Hide Add Button"
    7. To allow users to mark existing records for deletion, check "Allow Delete"
      • The LWC doesn't actually delete records. To delete the records
        • Set a record collection variable in the "Records to Delete" output under Advanced. Important: this collection must hold the same SObject as the "Record Collection" input variable
        • Delete the output record collection variable in the flow
        • See the Contacts path in the Sample Flow for an example of deleting records
    8. Click "Add/Edit Fields"
    9. Use the provided UI to add fields to display in the form
    10. In Advanced, Select "Manually assign variables" and:
      • Use "The Records" to define a record collection for the updated records to return to your Flow
        • Important: the record collection SOBject Type must be the same as the input "Record Collection" (3.iv) or your flow will fail
        • If you wish to save the changes made in memory and let users return the component to make additional changes, select the same SOBject Collection you used to input into the LWC
      • If deleting records, use "Records to Delete" to define a record collection to delete
        • Important: the record collection SOBject Type must be the same as the input "Record Collection" (3.iv) or your flow will fail
        • Allowing users to select records to delete requires checking "Allow Delete" in the inputs
        • The LWC doesn't delete the records. You'll need to delete them in the flow (see the Contacts path in the Sample Flow)
  4. If you are expecting users to edit existing records and add new ones, you'll need to assign those records to different collections for insert/upsert (based on whether or not they already have an Id) in the flow after the component. See the Contacts or Accounts paths in the Sample Flow for examples.

Caveats

  • Using lightning-record-edit-form means that this component is subject to Permissions and Sharing Settings
  • lightning-record-edit-form supports most, but not all, SObjects. For example, Event and Task are not supported. Read more here under "Supported Objects"
⚠️ **GitHub.com Fallback** ⚠️