I have a visual flow from which I want to pass some person account info to an invocable method. It seems that when I use a phone and email field I can't assign them to my invocable class. Is this because the invocable class only accepts primitive values or is there a way around?
Apex
public class CreatePersonAccount{
@InvocableMethod(label='Create Account' Description='Create an Account')
public static List<methodOutputs> invokeThisMethod(List<methodInputs> request) {
methodOutputs fo = new methodOutputs();
system.debug( request);
try{
Id personAccountRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('PersonAccount').getRecordTypeId();
Account newPersonAccount = new Account();
newPersonAccount.FirstName = request[0].FirstName ;
newPersonAccount.LastName = request[0].LastName ;
newPersonAccount.RecordTypeId = personAccountRecordTypeId;
insert newPersonAccount;
fo.DMLResult = 'Success' ;
} catch(Exception e){
fo.DMLResult = 'Error' ;
}
List<MethodOutputs> theResults = new List<MethodOutputs>();
theResults.add(fo) ;
return theResults;
}
//input details that come to apex from flow
public class methodInputs{
@InvocableVariable
public String Initials;
@InvocableVariable
public String FirstName;
@InvocableVariable
public String Insertion;
@InvocableVariable
public String LastName;
@InvocableVariable
public string Phone;
@InvocableVariable
public String Email;
@InvocableVariable
public date Birthdate;
}
//output details which goes from apex to flow
public class methodOutputs{
@InvocableVariable
public String test ;
@InvocableVariable
public String DMLResult ;
}
}