Questions tagged [invocable-method]

Invocable methods in Apex are called as invocable actions by the REST API and require the InvocableMethod annotation as an identifier. This can only be applied to one method in class and takes a maximum of 1 input parameter of a list of either a primitive data type, an sObject type or a user defined type.

Filter by
Sorted by
Tagged with
0 votes
1 answer
25 views

Passing an variable from flow to @InvocableMethod

I am super close to getting this process to work, however, I am a little unclear as to how to deal with the @invocableVariable portion of the process. And just to preface... I am NOT a coder, like at ...
1 vote
1 answer
54 views

Apex Class: Bulk Clone Records and Increment Field

I am working on an Invocable Apex Class to Clone Records based on a selected Objects. The base code I got from here is working well. Now I am trying to add logic to increment a field after the record ...
1 vote
1 answer
31 views

List has no rows for assignment in visualforce controller

There is a weird behaviour when referencing a visualforce page. I have a screen flow and I'm testing an Apex Action using @InvocableMethod. My method receives a List of Ids, and I use those to get a ...
2 votes
1 answer
34 views

Update field on related object

:) I want to update field on WorkOrderLineItem when the value on related product is changed (Product2). I don't have any error, but the field is not updated. Can you please take a look? @...
1 vote
0 answers
26 views

Can't access Session Cache from Invocable Method

I have a use case where a user fills out a form on one page, navigates to a second page, then starts an Einstein Bot flow, which I would like to have access to the values the user entered on the first ...
1 vote
0 answers
82 views

Error Occurred: An Apex error occurred: System.TypeException: does not have a no-arg constructor

I tried make an apex class with invocable Param, but i got Error Occurred: An Apex error occurred: System.TypeException: UT_Recalcuate_CallAction.recordInfo does not have a no-arg constructor when i ...
4 votes
1 answer
134 views

Why are my flow's input/output parameters not working with my InvocableMethod?

This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through ...
  • 445k
0 votes
1 answer
35 views

Apex CPU Error Timeout on Simple Invocable Method

When dataloading accounts - I keep getting an Apex CPU Timeout Error on the following action in the flow. There aren't many contacts on the accounts being passed in - (less than 20?) Am I missing ...
  • 143
0 votes
0 answers
43 views

Apex SOQL query works fine in tests but returns nothing from real database

I am having an issue where I have an invocable method that is receiving an Id for a record (in practise it will be receiving it from a flow), then based on that Id it searches for the object using a ...
  • 19
0 votes
0 answers
40 views

Apex Action in Flow is not executing when it's being called under guest user context

I have a managed package in my Salesforce instance, and I'm trying to implement a flow that is a record trigger flow on Event__c (custom object). I'm creating the Event__c record by exposing a URL ...
0 votes
1 answer
56 views

Invocable Apex Error: The number of results does not match the number of interviews that were executed in a single bulk execution request

I have researched StackExchange, as well as Salesforce Developer community. I cannot seem to get around this error. Ultimately, I am trying to pass into a screen flow a list of RecordTypes that a user ...
  • 3
0 votes
1 answer
44 views

Flow Invocable Apex- Error when running flow in bulk

I am trying to run a record triggered flow when multiple records are created. What I have now, works perfectly until I try to enter more than one Record at a time. I get the following error: The ...
's user avatar
0 votes
0 answers
36 views

Apex code to trigger email is not sending Email from Einstein bot

I'm calling an apex from Einstein bot to send an Email. The apex code is running fine and its returning success = True but I'm not receiving Email on the recipient side. I have checked access of apex ...
  • 1
0 votes
0 answers
26 views

Flow with a callout: how to avoid System.CalloutException: You have uncommitted work pending [duplicate]

I am creating a very basic flow. It is set that when record is updated and 1 specific condition is met that it will call an apex action that will call an api. I have set it up and the code is below ...
  • 129
0 votes
1 answer
40 views

Variable does not exist: invocable method

I am trying to pass 2 ID's into an apex action from a flow that just query's a subset of ID's and passes it back to the flow. I'm getting the following error for both my invocable variables inside the ...
-3 votes
1 answer
81 views

Unsupported parameter type Integer. Valid invocable parameters must be List types like List<T> where T is a supported type

I am trying to call this apex class from a flow but I run to this error, can anyone show me a better way to write this? Thanks global class NameGenerator { @InvocableMethod ...
3 votes
1 answer
99 views

What is the syntax for the iconName modifier in an Apex InvocableMethod?

The InvocableMethod docs say this about the iconName modifier: The name of the icon to use as a custom icon for the action in the Flow Builder canvas. You can specify an SVG file that you uploaded as ...
0 votes
1 answer
58 views

Apex Class CallOut

I'd like to apologize in advance as I'm quite new to writing APEX Classes / Triggers. I've followed a tutoriel of which the aim is to POST a comment to an external system, in this case it's Jira. I ...
0 votes
1 answer
64 views

Test class for HTTPCallout POST with Invocable Method from Flow [duplicate]

I'm still pretty new to this, and I've looked around and haven't been able to find the solution that combines everything like I'm trying to do. I've tried quite a few things, but here's where I ...
1 vote
2 answers
337 views

Flow InvocableAction returning an object with a list of objects

I'm looking to provide a Flow User with a list of Search Results based on a query. I have the following set of code, and haven't been able to figure out how to get it to work. (I've tried moving the ...
1 vote
1 answer
446 views

The number of results does not match the number of interviews that were executed in a single bulk execution request

I'm getting this error when I insert more than one record into an custom object that has a record-triggered Flow. Flow calls an invocable method to do parse multipicklist values. here's my invocable ...
0 votes
0 answers
448 views

External callout using Flow Builder - Apex Class Invocable Action

I would like to create a callout (webhook) when a custom field Batch_Name__c is updated which belongs to the Account Object. The purpose of this callout is to send all account information to an ...
  • 1
0 votes
1 answer
175 views

Flow using @InvocableMethod fails when inserting multiple records

I have an Apex class that matches Lead records to existing Contact records based on a phone number input. I'm using @InvocableMethod to include it in a Flow. The Flow works as designed when I insert a ...
  • 25
0 votes
1 answer
25 views

Flow executes only the first apex method

My flow which runs the apex code below just execute the first method. Is something missing to execute also the second method? public without sharing class MonthlyReport4FDB{ @InvocableMethod(...
  • 95
0 votes
1 answer
544 views

How can I pass maps to an Invocable Method?

I have a method in my code that I want to make into an invocable method: // This should be an invocable method with @InvocableMethod private void updateContacts(Map<Id,Contact> newContactMap, ...
  • 143
0 votes
2 answers
114 views

QueryException when using Invocable Method and SOQL

We have a flow that presents a multi-picklist on a screen that presents related Accounts. We then want to create a related object on each of those selected Accounts. To allow for modularity, we want ...
  • 77
-3 votes
1 answer
27 views

I am not getting full code coverage in my test class, is it because test data isn't setup correctly?

I'm new to Apex and have been working on a class as a training excersize. The invocable method works as expected when called from a flow but I'm having trouble getting the proper code coverage. I ...
  • 31
1 vote
1 answer
89 views

I need help resolving "unexpected token" error when setting up invocable variables in a test class

I have an invocable method with varables. I am stuck how to set these in a test class, below is the progress I've made. I am getting an errror "Unexpected token '='" on the last couple lines ...
  • 31
1 vote
1 answer
226 views

Invocable apex REST POST

I'm an admin who pretends to be a developer every once in awhile. I'm trying to use a Flow to initiate a REST POST callout. From other research, I understand this may need to be done with a future ...
  • 11
-3 votes
1 answer
63 views

How do you write test of Invocable Class?

I am calling this class from Flow to loop through picklist values inside the Position Picklist field. I am stuck at 53% coverage for my test class. The section between two == in the class is not ...
  • 13
-2 votes
1 answer
97 views

convert list with duplicate id to Map

I am working on an apex which is used to clear Hierarchy field values on User records when a user is deactivated. I am stuck at the last part of code. I have a List with same UserID but with different ...
-3 votes
1 answer
191 views

Test Class for an existing Apex Class

Apex Class public class DistanceRecord { public class FlowInputs { @invocableVariable public String AccountId; } @InvocableMethod public static void getAcct(List<FlowInputs&...
  • 1
2 votes
1 answer
1k views

Calling Future Method From Trigger

I am pretty stumped - I have a trigger on a custom object that calls a helper class that calls a future callout method. When I call the trigger, the helper class is called but I can't seem to get into ...
  • 3,245
0 votes
1 answer
1k views

How to iterate over List<List<String>> which is returned by Apex, in a flow?

I am invoking an apex class in my flow, which returns List<List< String>> back to the main flow. The flow surprisingly doesn't let me store the returned value in a collection variable. Now ...
2 votes
0 answers
209 views

Should an Apex class of utility methods which are invocable from Flows be implemented in the real world?

As I implied in a recent question, I know just enough Apex to be dangerous when trying to implement more complex concepts. (And by "complex" I mean "complex to me" because so many ...
  • 2,317
0 votes
1 answer
79 views

Is it possible to create a REUSABLE invocable method for serializing Apex Defined Variables (Wrappers) to be used in flows?

Edit: I've tried this by creating virtual/abstract class and setting it as the parameter for the invocable and then made an extension and passed it from the flow. Flow doesn't seem to allow this, it ...
  • 293
0 votes
1 answer
107 views

Invalid character in identifier: objProject_Contacts__c

I am trying to write an Apex class that will send emails to my project contacts. Still, I do face one error. I am not sure what I am doing wrong cause I am a beginner in Apex. public class ...
  • 3
0 votes
0 answers
75 views

How do I access the Collection Values within a Flow that are the result of an Apex Action Output value?

Hi I've added an Apex Action element to my flow which includes an output value. The Apex Action only returns one record but I understand it has to be returned as a nested list. The output value is a ...
0 votes
1 answer
368 views

Unable to Save a Flow that contains Invokable Apex action

Getting "Something went wrong. Hmm, that didn't work. Please try again." error while saving the screen flow that contains Invokable Apex action. Recently I did a modification on the apex ...
0 votes
1 answer
212 views

Can We Use Generic SObject With Custom MetaData Types getAll For Invocable Flow

We have an Invocable Apex Class to do SOQL which uses generic SObject in flow but returns an error the same if trying to use that Sobject for the Custom Metadata getAll method. global with sharing ...
  • 1,454
0 votes
1 answer
191 views

Invocable variable set default value

Is it possible to set default value for invocable variable? Didnt find any info. @InvocableVariable(Label='Var' Required=true) public String var = 'var';
1 vote
1 answer
203 views

Is There A Way To Pass Variable From Flow To Invocable Apex SOQL String

I'm using a very basic Apex Invocable Class from UnofficalSf to create SOQL queries from Flow and trying to see if there is any way I can pass one of the flow variables, such as {!vaname} or even ...
  • 1,454
0 votes
1 answer
116 views

Error on flow execution - The number of results does not match the number of interviews that were executed

I have a simple flow which is triggered from PB on record create. Thw flow is calling to Invocable Apex class in order to calculate business days and than - update the record. The process works just ...
  • 139
1 vote
0 answers
74 views

Getting Error while calling invokable method from Einstein Bot

I am getting this error in the log when calling an invocable method from Einstein Bot. Error: Attribute lookup failed for invocable action WorkflowValidateHelper at path /support/conversations/...
  • 11
0 votes
1 answer
65 views

Invocable Apex to compare 2 collections and get unique elements

We have a flow that loops through 2 objects (User & Email message) and stores its email addresses in 2 collections (Co11 and col2). I want to compare 2 collections and get unique elements before i ...
  • 55
0 votes
2 answers
84 views

Invocable Method + Variables -- Hitting Null Pointer Exception

I'm hitting a null pointer exception on an Invocable Method that I'm working on. I suspect that this is happening in the runClass method when I'm trying to convert my List of user ids ("userIds&...
0 votes
1 answer
98 views

How to convert List<sObject> to List<InnerClass>

I have a @InvocableMethod that is used from Flow builder to create a record. Also I have a inner class with @invocableVariable. It is working fine, but I want to use the same method from another class ...
  • 5
0 votes
0 answers
91 views

How to pass List<sObject> to @InvocableMethod that accepts only @InvocableVariable [duplicate]

I have a @InvocableMethod that is used from Flow builder to create a record. Also I have a inner class with @invocableVariable. It is working fine, but I want to use the same method to create records ...
  • 5
0 votes
0 answers
84 views

Generating a CSV through a report inside an invocable method THROWS exception, but in a normal method it doesn't!

I am trying to generate a CSV through an InvocableMethod but it throws an exception. If the same code runs in a normal method, then no exception is thrown. In the following code for example sendEmail2 ...
0 votes
0 answers
139 views

Test class for Invocable Method from Flow

I have been banging my head against the wall trying to work out how to write a test class that gets any coverage for this method, which takes values from a screenflow and returns a value back to the ...

1
2 3 4 5