Building on the knowledge of using the FlexCard and selecting Data Sources which is the important part of the step. Check my previous post of using FlexCard and Data Source Wizard tutorial here.
On this post we focus on using SOQL Query as the Data Source. We use the Salesforce Object Query Language (SOQL) to search the organization’s Salesforce data for specific information. SOQL is similar to SQL but specifically designed for Salesforce.
When using SOQL Query as a Data Source for the Flexcard, the results would be a table. It is used to display repeated rows of data, we can add WHERE clause or LIMIT clause.
- Though recordId is passed to a FlexCard through context when the LWC is embedded in record detail page, I can’t find a way a to use it in the SOQL query as WHERE clause.
- If security is a concern, use a DataRaptor instead of a SOQL query, because DataRaptors fully support field-level security.
Let’s Get Started
Create a new FlexCard and give it a Name, Title, Theme and Author. Keep Is Child Card to false and hit Next.
On the Select Data Source, choose SOQL Query.
On the next screen we can write our SOQL Query.
Select Id, Name, Phone, Website From Account LIMIT 10
We have the following options:
- Order By: Field to order the results
- Reverse Order: Set order to either ASC or DESC
- Fetch Timeout: Set timeout in milliseconds if query is taking longer.
- Refresh Interval: Set the interval in milliseconds to check for data changes.
HIt Next. On the Test Inputs screen, we won’t be using the test parameters. Hit the Save and Fetch to retrieve the results to test.
From the Build tab, drag and drop the Text Field to the canvas. Add the Fields like so using the Text Editor.
Activate the FlexCard. An LWC would be compiled from the FlexCard. Go to any account record and Edit the Page using the Lightning Page Builder.
Drag and drop the new LWC component to the layout.
Using the SOQL query is straightforward. Using SOSL would be similar but differnet syntas. These data sources usage really depends on the requirements. Bit of limited on filtering by context. Better to use DataRaptor or Integration Procedure which we will cover in future post.