A Graphical SOQL Query Builder for Flow, plus an Execute SOQL Action

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: [SELECT Account.Name FROM Contact...]
  • 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.

Future Developments

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.

Installation

Unmanaged V 1.1

View Source

Source

Old Versions

Unmanaged Packages V 1.0

6
Leave a Reply

avatar
4 Comment threads
2 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
4 Comment authors
SOQL Builder 1.1 Adds Related Fields and More – UnofficialSFAlex EdelsteinJake BullardChris VAdam White Recent comment authors
  Subscribe  
Notify of
Adam White
Guest
Adam White

It’s… beautiful.

Chris V
Guest
Chris V

Wow this is awesome. I can string those together with a few other actions to build a mass call campaign creation tool for the business.

One question, no test class for ExecuteSOQL.cls?

Jake Bullard
Guest
Jake Bullard

This is amazing and fits in perfectly with my next project which is a tool to allow a sales manager to create lists of given contacts for dialing. Very nice work. The only thing that is really a must for me is related fields but I can add that myself working from what you built here. Inner and our joins are also would be cool but I think it’s fine to leave that to the manual editing.

trackback

[…] For more information, see https://unofficialsf.com/a-graphical-soql-query-builder-for-flow/ […]