function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Thierry JORANDThierry JORAND 

Illegal argument in an invocable method

I encountered the following message in debug log :

Class.FlowContact.createCustomer: line 21, column 1 22:43:19.052 (52187112)|FATAL_ERROR|System.UnexpectedException: Illegal arguments

public class FlowContact {
    public class Customer {     
   @InvocableVariable
      public Contact inContact;
    }
   // Response
    public class Response {
      @InvocableVariable
      public String status;
    }
   @InvocableMethod(label='createCustomer' description='Call createCustomer ')     public static List<Response> createCustomer(List<Customer> customers) {         List<Response> resps = new List<Response> ();         Response resp = new Response();         System.debug('createCustomer Contact Id '+customers[0].inContact.Id);

         String strSalutation = customers[0].inContact.Salutation;
        System.debug('createCustomer Contact '+ strSalutation);  // line 21 is here        System.debug('createCustomer Contact fn '+customers[0].inContact.firstName);         System.debug('createCustomer Contact ln'+customers[0].inContact.lastName);         System.debug('createCustomer Contact n'+customers[0].inContact.Name);
        resp.status='0';
        resps.add(resp);
        return resps;
    }
 }

This method is called from a flow with firstname, lastname and Salutation which are fullfilled

Do you have any clue ?
Thanks in advance
ShashankShashank (Salesforce Developers) 
Could you please let me know if you are still facing this issue or if you found a solution?
Thierry JORANDThierry JORAND
I am still facing this issue.
But, as I can't stay stucked with that, I applied the following ( quite dirty) workaround :
public class FlowContact {
    public class Customer {     
   @InvocableVariable
      public Contact inContact;
   @InvocableVariable
      public String inSalutation;

    }
In the method createCustomer, I totally ignore the Salutation from the Contact object and use the replacement String inSalutation.
Francis HuangFrancis Huang
To fix this error, you have to wrap the multiselect picklist access in a String.valueOf():
String strSalutation = String.valueOf(customers[0].inContact.Salutation);