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
Rishabh Patel 1Rishabh Patel 1 

Pass Variables from flow to Apex, Cannot access invocable variable

I am trying to pass two variables from Flow to apex. One is a collection variable and another is just a string. 

Collection Variable is passed in personIds

And Passing String in inputName

I am trying to loop on the  Collection variable and update the name, But  i am not able to access the input name, as i can only create one method for personIds. 

global class lookupflowvars {
public with sharing class Requests {
  @InvocableVariable(label='Records for Input' description='test' required=true)
  public string inputName;
  }

   
     @InvocableMethod(label='Update Person Member Reference' description='Update MemberReference field on Person')
         
    
    public static void UpdatePersonMemberReference(List<List<String>> personIds){
   
    List<String> values = new List<String>();
    for (List<String> subList : personIds) values.addAll(subList);
         // List<Id> oppids= new List<Id>(); 
        List<Opportunity> oppList = new List<Opportunity>();
        oppList = [select id,Name__c from opportunity where id in :values];
        for (Opportunity newopplist : oppList ){
        newopplist.Name__c =inputName';   //cannot access  inputName here!
        update newopplist;
        }

    }
     
    
}

Cannot access inputName
Best Answer chosen by Rishabh Patel 1
AnudeepAnudeep (Salesforce Developers) 
Hi Rishabh, 

Can you try using getVariableValue method to retrievie your flow variable?

Please see https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_visualworkflow_vars.htm

You can also create a wrapper class : 

https://developer.salesforce.com/forums/?id=9060G0000005nusQAA

Anudeep