function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ethanoneethanone 

Apex in Flow

I need to allow a user to find a record of a custom object by either the Name or an external ID. I'm trying to build a search/lookup using Flow and it seems that if want even a little fuzziness in the search (OR logic), i need to use SOQL meaning i need to use Apex. Below is a basic example looking up accounts. I've added it to my flow, but I'm unable to get the list of accounts back to the flow for output. In fact, the flow won't even let my choose an appropriate variable (either an sobject collection or a collection variable). How do I get these results back into my Flow?
global class lookUpAccount {
    @InvocableMethod
    public static List<Account> getAccts(List<String> srchPhrases){
        List<Account> accts = [SELECT Id, Name FROM Account WHERE Name LIKE :srchPhrases];
        return accts;
	}
}

Since Dynamic Record Choice won't allow me to search by Name or ID, Is there is another approach to allowing a user to look for and select a record?
Raj VakatiRaj Vakati
If its salesforce flow , then use lightning component to do this work .. you can able to use the lightning component in flows 

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_using_flow_cmp.htm