With Spring ’20, it’s possible to create a Process Action (i.e. an Invocable Action running in Flow) that can return any kind of SObject. That means it’s finally possible to create an Action that executes any SOQL query it gets passed.
In this instance, an ExecuteSOQL action has been configured to take a SOQL string as an input and return a collection of Accounts:
This milestone means it’s now worthwhile to build a Flow Screen component that can be used to generate SOQL queries:
The SOQLBuilder LWC can take an existing SOQL string and will try to parse it and display it in the UI. It will output a string based on whatever is generated in the builder.
Note that when configuring the Execute SOQL Action, it’s necessary to specify the object type that will be returned. Make sure that the Object Type specified in the SOQLBuilder matches. In other words, if you have an Execute SOQL action in your flow that’s hard configured to return Contact records, don’t pass it a string that queries on Accounts.
New Features in V1.1
- You can now traverse to select related fields via relationships (example:
- An ‘Add All’ button lets you easily create the equivalent of a Select *
- You can lock down the object that the query is returning by setting the attribute disableObjectTypeSelection to True. This is useful when you’re pairing this component with an Execute SOQL action, because the action has to be locked to a specific action type in the Flow Builder, and this avoids the user selecting a different action and ending up with a mismatch.
By the end of 2020, it will be possible to add Custom Property Editors to Collection Processor Actions. That will allow the SOQL Builder UI to not just exist in running Flows but also in the Execute SOQL property editor in Flow Builder.