1

In my Process Builder, on creation of my custom Object Bank__c record, I want to pass two parameters(Ids, objectApIName) to InvocableMethod in Apex class, so I added this to my code,

public static List<Id> idList = new List<Id>();
public class Request{
    @InvocableVariable(required=true)
    public List<Id> ids;
    @InvocableVariable(required=true)
    public String objectAPIName;
}

@InvocableMethod
public static void mergeAccounts(Request[] requests) {
    String objectAPIName; // Object API Name
    for (Request mp : requests) {                
        idList.addAll(mp.ids);
        objectAPIName = mp.objectAPIName;
    }
      ---
      ---
}

But when I am trying to add "ids" variable with RecordId in Process Builder it is giving me this error "The input parameter "ids" can accept multiple values, so the assigned value must be a flow variable with the isCollection property set to true."

Is there any way I can pass the RecordId's into my Apex class just from PB instead of also using Flow. Let me know. Thank you!

3

You can't. You'd have to change the variable to Id instead of List<Id>.

| improve this answer | |
  • Thanks Sfdxfox.. if I just add Id, can you suggest me how can I modify my code to add that Id into List<id> I want to add "public Id ids;" to "public static List<Id> idList = new List<Id>();" this list? – user62694 Apr 12 at 6:24
  • @user62694 You would iterate through the Request array and get the ID values from each. This is how the bulkification works for the flow engine. – sfdcfox Apr 12 at 7:27
  • Got it, thank you so much!! – user62694 Apr 12 at 8:01

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.