I have a flow where I am passing a Custom Object's recordId to the flow by invoking it from a detail page button like this /flow/Activate_Record/myRecordId?={!Inactive_Farms__c.Id} This flow is invoking a Apex class with parameter List<Inactive_Farms__c> iFarms. Now, can someone help me understand if the button is clicked by multiple users at the same time, is it considered as a single transaction? Is the why InvocableMethod allows only List type? I am not able to determine if I have to query as Inactive_Farms__c if = [Select Id, Farm_Id From Inactive_Farm__c Where Id = :iFarms assuming only one record per click


Query List<Inactive_Farms__c> if = [Select Id, Farm_Id From Inactive_Farm__c Where Id IN :iFarms] because multiple records will be passed?

Thanks in advance


InvocableMethods can be called from autolaunched flows (process builder), which could be operating on multiple records at once. For this reason, their inputs can only be List types. Different users always have separate transactions.

If your method accepts List<Inactive_Farms__c> iFarms, then the flow should retrieve the records, and the method won't need to query. The method could also accept List<Id> iFarms, which relieves the flow of record retrieval, and requires a query. Use the List<Inactive_Farms__c> if = [Select Id, Farm_Id From Inactive_Farm__c Where Id IN :iFarms] query if you are taking the List-of-IDs approach.

Either way, loop through the list in the method. In your page button scenario, this list will only contain one record, but you need to account for the possibility that other records will be included if invoked from somewhere else.

  • Thank you @MatthewGTS. That is exactly what i wanted to hear. I thought i might over complicating the logic making it accountable for multiple records.
    – SunnyG
    Nov 28 '19 at 15:03

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.