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?


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);
            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{
        public String Initials;
        public String FirstName;
        public String Insertion;
        public String LastName;
        public string Phone;
        public String Email;
        public date Birthdate;
    //output details which goes from apex to flow
    public class methodOutputs{
        public String test ;
        public String DMLResult ;
  • email and phone are stored as string primitives in back end, so that can't be the issue, what exact issue are you facing here? – rahul gawale Dec 30 '19 at 17:12
  • @rahulgawale You can literally copy this class and check by adding a phone or email variable into a screen flow to an apex action and see this cannot be passed to the invocable. – Thomas Dec 30 '19 at 18:57
  • 2
    Please edit and show the portions of the Flow (including relevant data elements) that you are trying to pass to the invocable apex – cropredy Dec 31 '19 at 0:51
  • 1
    @Thomas I tried, it is working fine for me. Please add your flow screen shots – rahul gawale Dec 31 '19 at 3:00
  • @rahulgawale did you used a the type phone or type email in your variable of the flow instead of text? With text of couse ther are no issues – Thomas Jan 3 '20 at 12:56

I resolved this by using a text field and do the validation trough regex apex. Below is my example:

emailRegex = '^[a-zA-Z0-9._|\\\\%#~`=?&/$^*!}{+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$'; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.