In this blog, we will discuss on how to invoke an Apex class from a Screen Flow through an simple example. In this example, we have created a Screen Flow in which we have created three variables. First one is recordId which is set as available for Input and Output both.

The second variable that we have created is the Account to store Account Data.

The third variable that we have created is Name. That stores the return value of the Apex class called in the flow.

Then we create an Invocable method in class InvokeAccountAction.apxc which will be called through the Screenflow to return the Name of an particular Account as follows:
public class InvokeAccountAction
{
@InvocableMethod(callout=true label='Get Account Name')
public static List<String> getAccountNames(List<ID> ids) {
List<String> accountNames = new List<String>();
List<Account> accounts = [SELECT Name FROM Account WHERE Id in :ids];
for (Account account : accounts) {
accountNames.add(account.Name);
}
return accountNames;
}
}
Meanwhile, to call the Apex class from the flow we create an Apex action in the flow as shown in the image below:

For example, after calling an Apex class we want to make sure that the return value against the field Name of the particular Account is not empty.

After that, we create a screen to show the name of that Account, if the condition is satisfied.

Likewise, the whole flow can be built as shown in the image below:

Likewise, after you have completed built the flow you can create a Button Invoke Method to call the flow:

After execution of the flow, we get a Screen which shows the Account Name as shown below:

We hope that you find this blog helpful, if you still have queries, don’t hesitate to contact us at salesforce@greytrix.com.
About Us
Greytrix – a globally recognized and one of the oldest Sage Development Partner and a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners and Sage PSG across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.
Greytrix has some unique solutions for Cloud CRM such as Salesforce Sage integration for Sage X3, Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data Migration, Integrated App development, Custom App development and Technical Support to business partners and end users.
Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star rated app listed on Salesforce AppExchange.
The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.
For more information on our Salesforce products and services, contact us at salesforce@greytrix.com. We will be glad to assist you.
Related Posts