Apex defined variable in Salesforce Flow

by Rijwan Mohmmed
apex-defined-variable-in-salesforce-flow-techdicer

Hello friends, today we are going to discuss how to use Apex defined variable in Salesforce Flow. With the Apex-defined data type, flows can manipulate the kinds of complex data objects that are typically returned from calls to web services. Create Apex-defined variables in flows and directly process JSON returned from web calls. We create a wrapper class without any extra method and all variables should be @AuraEnabled can be use in Flow Apex Defined Data Type.

Also, check this: Lightning Progress Indicator in LWC

Key Highlights :

  1. Handle complex data.
  2. Apex-defined resources are useful for connecting flows to rich external web objects accessed via Mulesoft and REST calls.
  3. The Apex-defined data types allow admins building Flows to collect multiple sub-variables into one outer variable, similar to how we create a wrapper class for JSON data.
  4. The @AuraEnabled annotation for each field is required.
  5. A constructor with no arguments is required.
  6. Class methods aren’t supported.
  7. Supported data types in an Apex class are Boolean, Integer, Long, Decimal, Double, Date, DateTime, and String. Single values and lists are supported for each data type. Multiple Apex classes can be combined to represent complex web objects.
  8. Only screen flows and auto-launched flows are supported.

Code :

ApexDefinedDataType.cls :

// Apex-Defined Variable Class
public with sharing class ApexDefinedDataType {
    // @AuraEnabled annotation exposes the methods to Lightning Components and Flows
    @AuraEnabled
    public String firstName;
    @AuraEnabled
    public String lastName;
    @AuraEnabled
    public Boolean email;
    @AuraEnabled
    public Integer phone;
}

Step 1: Here we create a variable in which we use apex-defined data type.

Step 2: In this step, we assign the values in apex-defined dataType.

Output :

Reference :

  1. Salesforce Lightning Flow
What’s your Reaction?
+1
3
+1
1
+1
0
+1
0
+1
1
+1
2

You may also like

Leave a Comment