Suppose I have this structure:
The class with @InvocableMethod
:
global with sharing class GetAllOrgsAction {
global class responseObjectAPI {
@InvocableVariable global List<DTO.Organization> data;
@InvocableVariable global DTO.Meta meta;
}
global class requestObject {
@InvocableVariable global String access_token;
@InvocableVariable global Integer page;
@InvocableVariable global Integer per_page;
global requestObject() {}
global requestObject(String access_token, Integer page, Integer per_page) {
this.access_token = access_token;
this.page = page;
this.per_page = per_page;
}
}
@InvocableMethod(Label='Get a list of organizations')
global static List<responseObjectAPI> run(List<requestObject> requests) {
Http http = new Http();
List<responseObjectAPI> responses = new List<responseObjectAPI>();
for (requestObject request_i : requests) {
HttpRequest req = /*...*/;
HttpResponse res = http.send(req);
responses.add((responseObjectAPI) JSON.deserializeStrict(res.getBody(), responseObjectAPI.class));
}
return responses;
}
}
The DTO
class:
global with sharing class DTO {
global class Auth {
@InvocableVariable global String id_token;
@InvocableVariable global String token_type;
@InvocableVariable global Integer expires_in;
@InvocableVariable global String access_token;
@InvocableVariable global String refresh_token;
}
global class Meta {
@InvocableVariable global Integer total;
@InvocableVariable global Integer current_page;
@InvocableVariable global Integer per_page;
@InvocableVariable global Integer last_page;
}
global class Organization {
@InvocableVariable global String id;
@InvocableVariable global String name;
@InvocableVariable global String subdomain;
@InvocableVariable global String category;
@InvocableVariable global String size;
@InvocableVariable global String status;
@InvocableVariable global String created_at;
@InvocableVariable global String updated_at;
}
}
I am calling Apex Action from salesforce flow. For the output I have data
array and meta
object, but I cannot get any property of meta
object, for example, last_page
.
Am I missing something? The documentation says:
The data type of the invocable variable must be one of these:
A list or a list of lists of primitives, sObjects, objects created from Apex classes, or collections
Just for your information. In this case (code example below) I can access properties of DTO.Auth
:
global with sharing class AuthAction {
global class requestObject {
@InvocableVariable global String username;
@InvocableVariable global String password;
global requestObject() {}
global requestObject(String username, String password) {
this.username = username;
this.password = password;
}
}
@InvocableMethod(Label='Get access token (Password grant)')
global static List<DTO.Auth> run(List<requestObject> requests) {
Http http = new Http();
List<DTO.Auth> responses = new List<DTO.Auth>();
for (requestObject request_i : requests) {
HttpRequest req = /*...*/;
HttpResponse res = http.send(req);
responses.add((DTO.Auth) JSON.deserializeStrict(res.getBody(), DTO.Auth.class));
}
return responses;
}
}