1

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

1 Answer 1

3

You can't access it, because it's in a different class. You need to pass in the request as a parameter:

public static void UpdatePersonMemberReference(List<Requests> people){

You should include the "personIds" as another InvocableParameter as well. Check the documentation for an example.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .