Posts

Salesforce Fact #923 | Find out matching leads/contacts using screen action

Image
Another use case using Screen flow action(Beta). We can have a screen flow to take email Id as input and find out what all existing contacts and leads are present with the same email. For this, we create a subflow to fetch the contacts and leads based on the input email passed. Also, to avoid unnecessary fetching of records, we can add validation to ensure the get records are performed only when the email is of valid email format. And in the main flow, we can refer the subflow in screen action and show the matching contacts or leads instantly. Attached are the screenshots.

Salesforce Fact #922 | Cloned from which record

Image
Suppose we want to track the record from which a record is cloned. We can make use of the isClone() and getCloneSourceId() functions in apex. Reference:  https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_sobject.htm#apex_System_SObject_getCloneSourceId Attached is sample code screenshot.

Salesforce Fact #921 | Figuring out duplicate account names in screen flow

Image
Suppose we need to find out the duplicate account names in the screen flow. We can get that using collection filter, transform elements. In this example, we have taken two account type collection: DefaultAccCollection(which stores all the account records) and DuplicateAccCollection(which stores the account whose names are duplicate). And at the end, we can use a transform element to extract the names from collection. Attached are the screenshots.

Salesforce Fact #920 | Query OWD

We can query the OWD of standard and custom objects using EntityDefinition object. The ExternalSharingModel and InternalSharingModel fields refer to the default external and internal access respectively. Sample Query: SELECT DeveloperName, QualifiedApiName, ExternalSharingModel, InternalSharingModel FROM EntityDefinition The possible values are: Private Read -> Public Read Only Edit -> Public Read/Write ControlledByParent ControlledByCampaign

Salesforce Fact #919 | Remove selected UT2A records using screen action

Image
In continuation of the last post related to screen action, we can extend the logic to remove a user from selected territories.  The subflow returns the UserTerritory2Association records for the input userId and in the main flow, the result is shown in datatable allowing the user to select a record and then proceed with the deletion. Attached are the screenshots. Note: For demonstration purpose, used the Territory2Id field for storing the territory label but it is not advised to follow.

Salesforce Fact #918 | Pass value from LWC to embedded screen flow reactively

Image
Suppose we have an embedded screen flow in LWC and we are passing data from lightning record picker in LWC to the screen flow and we want that the change in record picker is reflected in screen flow instantly. We can achieve the same using bit of LWC logic. Reference:  https://salesforce.stackexchange.com/questions/408371/how-to-dynamically-change-flow-embedded-inside-lwc Attached are the screenshots.

Salesforce Fact #917 | Screen action in action

Image
With the Spring'25 release, we now have access to Screen Actions(Beta). It takes a step ahead in the action button setup by introducing reactivity, without requiring a button click. In this example, we have created an autolaunched flow which takes the userId as input and finds out the UserTerritory2Association records for that user. We are calling the flow from the screen action which shows up the data instantly based on the user selected in lookup. No more button clicks needed! Attached are the screenshots.