Skip to main content

#Invocable Actions2 人正在讨论

After the org was upgraded to Winter ’27, the AIAgentAPIV1

action started throwing errors in the flow. If I reselect the action, it no longer allows me to configure any parameters. 

 

AIAgentAPIV1 No Longer Works in Salesforce Flow in Winter '27

 

 

image.png

 

 

 

 

#Agentforce  #Salesforce Developer  #Salesforce Admin  #Flow  #Invocable Actions

2 个回答
  1. 9月1日 01:20

    Thanks @Abhishek R

     

    The documentation is correct, but the action configuration screen in Flow looks strange. There’s nowhere to set these required parameters.

0/9000

[▶️]🔴🔥🎬 Call Apex Invocable Method From Salesforce Flow - Part 1 

 

Learn how to call Apex methods from Salesforce Flow in this two-part series! This first video covers a simple use case: passing a single input type to Apex and receiving single output type back into your Flow. Perfect for beginners! 

 

🎬 https://youtu.be/Gvfvgrs7WDw 

📒 https://sudipta-deb.in/2025/01/call-apex-invocable-method-from-salesforce-flow-part-i.html

 

 

#Apex #Flow #Invocable Method #Invocable Actions

 

@The Blog Group

 

[▶️]🔴🔥🎬 Call Apex Invocable Method From Salesforce Flow - Part 1 Learn how to call Apex methods from Salesforce Flow in this two-part series! This first video covers a simple use case: passing a si

 

 

0/9000

If you are coming to TDX, please check out our session on Extending Flow with Invocable Actions and HTTP Callouts.   Attached is a file with all of the Resources covered in the presentation.  After TDX, check the comments for a link to the final Slide Deck as well as a link to the session recording.  Learn more about Invocable Actions, HTTP Callouts, Custom Property Editors and Reactive Flow screen Components.

 

#Flow #Screen Flow #TDX24 #Custom Property Editor #Invocable Actions

1 条评论
  1. Eric Smith (Retired) Forum Ambassador
    2024年3月29日 19:24
0/9000

I am creating an Apex action according to the info described here, using custom defined objects for passing in the request and out the result.

 

Having defined those objects, in flow, I am able to create an apex-defined single-value variable for the request object type as well as a collection of that object type.

 

However, when I try to invoke the apex action, it only allows me to enter the single object variable and not the collection one.

 

My understanding is that the Apex action is expecting a List of these custom objects.  So I initially defined the method for this action as follows:

 

global class FindOrCreateContacts {

@InvocableMethod(label='Find or Create Contacts' category='Contact')

global static List<FOCCActionResult> GetIDs(List<FOCCActionRequest>> requests) {

...

With the custom object defined as:

global class FOCCActionRequest {

@InvocableVariable(required=true) @AuraEnabled

global String email;

@InvocableVariable(required=true) @AuraEnabled

global String lastname;

@InvocableVariable @AuraEnabled

global String firstname;

@InvocableVariable @AuraEnabled

global String country;

}

This is how it is shown in the example code on that page.  However, when I tried to invoke the action from flow, it was requesting the individual variables of the class (email, lastname, firstname, etc.) instead of an instance of that class.

 

OK, so I changed the method signature to:

global class FindOrCreateContacts {

@InvocableMethod(label='Find or Create Contacts' category='Contact')

global static List<List<FOCCActionResult>> GetIDs(List<List<FOCCActionRequest>> requests) {

Now in Flow, it asks for an instance of requests, but it will only allow me to select a single instance variable but not a collection of those objects.

 

I tried adding another layer of List< to the method signature, but that was not accepted.

 

Can anyone tell me what I'm doing wrong?    Thanks!

 

#apex #Flow #Invocable Actions

3 个回答
  1. 2023年3月2日 18:14

    Here's the full source of this (I hope!) useful function, in case anyone is interested.

     

    global class FindOrCreateContacts {

    @InvocableMethod(label='Find or Create Contacts' category='Contact' description='Called by flow Upload CNVC CSV to return a list of all transactions passed to it with the ContactIDs and AccountIDs added')

    // This method makes use of a custom object created in the host system called "CNVC_Import__c".

    // This allows us to pass and manipulate data as SObjects for convenience. However, we never write them to the database.

    global static List<List<CNVC_Import__c>> GetIDs(List<List<CNVC_Import__c>> requests) {

    // Because Flow expects lists of lists as input and output, create "results" variable and then create the first list inside the first list

    List<List<CNVC_Import__c>> results = new List<List<CNVC_Import__c>>();

    results.add(new List<CNVC_Import__c>());

    // These are sets to ensure uniqueness so we only create users once if they appear more than once

    Set<String> allEmails = new Set<String>();

    Set<String> allNewEmails = new Set<String>();

    Set<String> foundEmails = new Set<String>();

    // Used as lookup tables to link emails to Contact and Account IDs

    Map<String,ID> contactIDs = new Map<String,ID>();

    Map<String,ID> accountIDs = new Map<String,ID>();

    system.debug('Input' + requests);

    // Extract all emails from input records into a set which will be used to look them all up at once

    // We're referencing "requests[0]" because it was passed as a list of lists.

    for (CNVC_Import__c request : requests[0]) {

    allEmails.add(request.Email__c);

    }

    system.debug('allEmails set:' + allEmails);

    // Find any contact records that have an email from the request list

    List<Contact> existingContacts = [SELECT Id, FirstName, LastName, Country__c ,AccountId, Email FROM Contact where Email in :allEmails];

    system.debug('Existing Contacts' + existingContacts);

    // Add existing contact IDs to contactIDs and AccountIDs lookup maps

    for(Contact contact : existingContacts){

    contactIDs.put(contact.email, contact.Id);

    accountIDs.put(contact.email, contact.AccountId);

    foundEmails.add(contact.Email);

    }

    //system.debug('FoundEmails after adding existing' + foundEmails);

    //system.debug('Results after adding existing' + results[0]);

    // Now loop through request records and prepare to create any emails not already found

    List<Contact> newContacts = new List<Contact>();

    for (CNVC_Import__c request : requests[0]){

    if (foundEmails.contains(request.Email__c)) {

    system.debug('Was Found: ' + request);

    // Do nothing - Contact already exists

    } else {

    system.debug('Adding New: ' + request);

    newContacts.add(new Contact (LastName = request.Lastname__c,

    FirstName = request.Firstname__c,

    Email = request.Email__c,

    Country__c = request.Country__c));

    // Add to list of IDs for later query to get AccountIDs

    allNewEmails.add(request.Email__c);

    }

    }

    system.debug('Newcontacts before insert' + newContacts);

    // Now insert list of contacts

    try {

    insert newContacts;

    } catch(DMLException e) {

    return null;

    }

    //system.debug('Newcontacts after insert' + newContacts);

    //system.debug('Results after insert' + results);

    // Now retrieve those same new contacts. We have to do this so we can get access to the accountIDs.

    // Because we are on NPSP with house accounts, accounts get created automatically as Contacts get created,

    // but their IDs are not available unless you query for those contacts.

    List<Contact> retrievedNewContacts = [SELECT Id, AccountId, Email, Firstname, Lastname, Country__c FROM Contact where Email in :allNewEmails];

    //Add new contacts IDs to Maps for ContactIDs and AccountIDs

    for(Contact contact : retrievedNewContacts){

    contactIDs.put(contact.email, contact.Id);

    accountIDs.put(contact.email, contact.AccountId);

    }

    // Now we add any newly-created contact info into the results list of Sobjects

    For (CNVC_Import__c trans : requests[0]) {

    results[0].add(new CNVC_Import__c(

    Firstname__c = trans.Firstname__c,

    Lastname__c = trans.Lastname__c,

    Country__c = trans.Country__c,

    Email__c = trans.Email__c,

    Contact_ID__c = contactIDs.get(trans.Email__c),

    Account_ID__c = accountIDs.get(trans.Email__c),

    Amount__c = trans.Amount__c,

    Date__c = trans.Date__c,

    Existing_User__c = foundEmails.contains(trans.Email__c)));

    }

    system.debug('Final Results' + results);

    return results;

    }

    public virtual class CNVCException extends Exception {}

    }

0/9000

Check out my newest post on @UnofficialSF Discussion on two handy actions that will let you refresh or recalculate formulas on a record collection in Flow!

 

https://unofficialsf.com/re-calculate-formulas-or-refresh-record-collections-with-these-handy-actions/

 

@Salesforce Flow Automation, @Lightning Flow Discussions 

 

I've also started my own Blog! https://medium.com/@DeclarativeNinja

 

Let me know what you guys think of the actions in the comments section!

 

Thanks @James Hou for the great action!

0/9000

Maybe a little technical but is there a way to resume a Flow after an @Future Apex method is completed? Right now I have an arbitrary Wait element but that's a hack workaround and not reliable of course.

4 条评论
  1. 2018年11月15日 19:52
    @Darrell DeVeaux

    +1

    @Gorav Seth

    's solution. We have implemented an @future method called through an Invocable Method. The @future method creates a response object record that we "wait" for and then continue processing. It is useful because the @future response is bringing back information that we need. This won't work too well in a screen Flow, though...

    From a reliability standpoint, we have a loop counter in the Wait/Record Check loop to terminate and create a Flow Log record if the anticipated response record is not created in a reasonable period (three wait cycles for us)

0/9000

If you are using Apex Invocable Actions in your Process Builder be careful. This Known Issue is more broad then the way it is written here. These can just disappear from your Process Builder and for more than just standard fields.

This was a Known Issue in the Spring release and the workaround was "dont use them". It was marked as fixed in the Summer but it is not. I have a Process that ran last night and errored wildly. Open this morning and I see there are no Actions in the steps. Each of these had Apex Invocable actions as steps and they were there on July 29 at 5:10PM.

https://success.salesforce.com/issues_view?id=a1p300000008ZFDAA2
0/9000

I'm not understanding the return values for Invocable Actions using Flow and been going crazy last 2 days.

The docs say we can use lists of any primitive data, except generic Object. So I'm returning a list of Dates. How can Flow store that? Even if I make a Collection variable, it does not appear on the Output tab. The only variables appearing are Sobject and regular variables but you can't store a list in a regular variable???

Am I missing something or is the answer that the only return values for this using a Flow is an Sobject OR a SINGLE value?? If single, then I'd need to call this within a loop..which is bad.

7 条评论
  1. 2015年2月15日 04:57

    It doesn't seem like this was intended. As a workaround, you can declare a string in your method and return the string entire string and parse through it to assign the values to an sObject; totally not desirable but it works. So you can take advantage of it if you really need to use some custom apex logic.

    But yes, collection and sObject collections should be an option in the outputs / inputs panes based on the release notes. Sometimes it's not looking for what's there, but is looking for what's not.

    P.S. I can't believe I missed this earlier! I just retrieved one object back when testing and didn't think anything of it! >< Good eye

    @Darrell DeVeaux.
0/9000
@Bill Takacs@Shelly Erceg

Can you confirm if the Flow Designer error "Can't Load Invocable Actions" that is thrown when an instance has Person Account Actions is going to be resolved in Spring'15 production release?

Loading flows in Flow Designer error if org has a quick action defined on Person Account (Reference W-2477447)

https://success.salesforce.com/issues_view?id=a1p300000008XigAAE

Overview of Issue:

If you have Global Actions defined for person accounts, then when the Flow designer is loaded an error is displayed and all actions (Static Actions, Custom Action and Email Alerts) are missing from the Flow designer palette

If the actions are deleted, Flow designer actions are restored.

0/9000