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
Jeremy Thomas 15Jeremy Thomas 15 

Run Apex Method on Record Creation in Flow

I am trying to set up a flow to run an Apex method after an Account gets created.

I can create an InvocableMethod and have it show up as an Action in a Flow.

The issue I'm having is understanding how to connect the dots. InvocableMethod requires you send in a List of items (so List of Accounts in my case?), but I want to be able to run my method every time an Account gets created, so not a List of Accounts but an individual account.

The Flow trigger for record creation obviously returns only one Account, so how do I set up my Flow so that I can run an Apex class on an Account after it gets created?
Best Answer chosen by Jeremy Thomas 15
Jeremy Thomas 15Jeremy Thomas 15
Figured it out. It seems in a Flow you can pass a single object to InvocableMethod Apex Action even though it takes a List as input. So I connected my Record Trigger directly to my Action with Apex Method to use the $Record.

All Answers

Jeremy Thomas 15Jeremy Thomas 15
Figured it out. It seems in a Flow you can pass a single object to InvocableMethod Apex Action even though it takes a List as input. So I connected my Record Trigger directly to my Action with Apex Method to use the $Record.
This was selected as the best answer
PriyaPriya (Salesforce Developers) 

Hi Jeremy,

Yes Correct we would have to send a list type. In apex we can query it again and proceed. For example, refer this below link:- 
https://automationchampion.com/tag/call-an-apex-method-from-flow/
 similar to this process builder in example.

If the above information works, please mark it as best answer.
 

Regards,

Priya Ranjan