Questions tagged [future]

A future method runs in the background, asynchronously. You can call a future method for executing long-running operations, such as callouts to external Web services or any operation you’d like to run in its own thread, on its own time.

Filter by
Sorted by
Tagged with
0
votes
0answers
28 views

Create dependent callount in triggers [closed]

In our org, we have triggers on Account and Contact that each make future callout to push it in an other system. It work fine. Now I have to create a Screen flow, between two screen I have to create ...
-1
votes
2answers
52 views

DML in a future method will be rollback if after there's a throw exception

My classA calls classB which calls a future method inserting an object, later in classA it throws an exception, and I saw my DML in future method is also being rollbacked. Is there anyway to commit ...
0
votes
1answer
59 views

Salesforce @future not working [closed]

I am sending the request to the docusign in salesforce apex triggers. The apex triggers call the external class and then the method call the http request. If I use the @future on top of the method,...
0
votes
1answer
31 views

Question for confirmation: Callout from Trigger using Platform Events

After a record is updated in Salesforce, i need to perform a callout to synchronize data to an External System. Ideally, i would like to do this kind of synchronously, however it doesn't seem to be ...
5
votes
2answers
1k views

Preventing Recursive Future Calls

I have a usecase where when an account is updated, an after update trigger is fired. This trigger will call a future method which will call a SOAP API to assign the relevant territory assignment rules....
3
votes
1answer
742 views

Testing @future method Failed Assertion

I have some code that after inserting a task, calls an @future method to update some fields on the contact linked to that task (WhoId). This seems to work fine in sandbox, but I can't seem to get it ...
1
vote
0answers
30 views

Guest User can perform update under future method

I have a site page with a form that can be accessed by guest users. I have an upload button that when it's clicked a tracking record is created (it's ok for guest user as the profile has read/create) ...
6
votes
2answers
1k views

How to test @future methods with setup objects and avoid MIXED_DML_OPERATION

I’m in a situation where I have to use a future method to avoid MIXED_DML_OPERATION error. I have a trigger that runs after INSERT on USER and creates a custom object X. They are in 1:1 relation. ...
0
votes
0answers
23 views

Was trying to get the Data from the API Endpoints and Insert into Salesforce Org

I am new to the Salesforce Developer and was trying to do something where I was trying to fetch the data from the API endpoints and Insert into my Object of salesforce Org. Using the Future ...
7
votes
1answer
10k views

Error: Future method cannot be called from a future or batch method

I have a managed packaged that I recently updated and it threw an error for a future method I have that sends information to a third party. The error I received was: Future method cannot be called ...
0
votes
0answers
24 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 ...
4
votes
1answer
3k views

Issue creating user and setting password

I am experiencing an issue creating users and setting their password. I have a need to setup a great deal of users but only activate them as they attempt to login. The creation process and activation ...
1
vote
1answer
32 views

UNKNOWN_EXCEPTION, portal account owner must have a role: In Future Method

When a contact is created I am trying to create community portal user. So first I wrote the user creation code in trigger itself but I got the error 'MIXED_DML_OPERATION'. So I moved my user creation ...
0
votes
0answers
58 views

How do I write test methods for a @future method in a SandboxPostCopy class?

My team uses a sandbox for user onboarding, so I wrote a SandboxPostCopy class to populate the training sandbox with sets of records and create test users on refresh. The class compiles and, as far as ...
4
votes
2answers
2k views

Is it possible to handle Trigger.oldMap in @future method?

I've got a class with an @future annotated method that gets called in an after Trigger context variable (it's an asynchronous callout, so it needs to be in Trigger.after) and performs Database.update(...
0
votes
1answer
37 views

Invoking inter dependent callouts from a managed package

I have a requirement, where I have a scheduled apex which runs every 5 mins and invokes a future method of an apex class. This future method invokes a managed package method for making the callout. So ...
7
votes
2answers
9k views

Getting current PageReference from Controller Extension in @future context

I'm attempting to get current pageReference for a VisualForce page (renderAs=pdf) that is being executed in @future context, but at the moment it is just returning a null. So I assume the problem is ...
2
votes
0answers
55 views

Apex Test not able to execute Queueable and Future in same user context?

Scenario -> Queueable calls a Future method In business process the Queueable calls another future method and future executes in same user context as its having some CRUD and FLS checks. Now when ...
1
vote
1answer
64 views

Why does Future and Queueable or any Async rollback or does not get called when an exception is occurred in Main Thread?

I was trying to test if Async opens up a new thread or is tied to the main thread and the result was very interesting. Consider this class: public with sharing class TestClassTest { public static ...
0
votes
1answer
50 views

Testing triggers with future methods

According to my functionality: insert and update calls a trigger that invokes future methods. In my test case, I need to test the update functionality. In order to test the update functionality, I ...
15
votes
3answers
15k views

Future Method calling Another Future Method

I have two future methods f1 & f2. Each of them takes long time to process as such I have annotated them as @future. There is a scenario in which I need to make a callout to f2 from f1. Any ...
2
votes
1answer
495 views

Unauthorized endpoint when calling Metadata API from Apex in @future

I am running into the exception IO Exception: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://eu25.salesforce.com/services/Soap/m/42.0 when ...
1
vote
1answer
1k views

show error message after delay in lightning

Here is the situation. I have a @Future method which has callouts is running along side of actual main CLASS. in the callout response, I am receiving some error/success XML, I am saving them in a ...
1
vote
1answer
33 views

How can we access visualforce page for pdf generation from a future annotated method

I have a future annotated method which should generate a pdf in PdfController, the method is as below: @future(callout=true) public static void savePdfAsAttachment(Id applicationId){ PageReference ...
0
votes
1answer
49 views

Salesforce Process Builder Apex Error: Too Many Future Calls

I've created an SalesForce Process that automates the creation of Asana projects for my org. This works well in small-scale, however when many data updates happen at once, we receive an error; Error ...
0
votes
0answers
26 views

Restrict user deactivation if Account is owned by the user and send an Email with details

please help. I am new to SFDC please help. Requirement: Restrict user deactivation if Account is owned by the user and send an Email with details. Trigger on user object: trigger userTrigger on ...
1
vote
1answer
81 views

Future Class triggering two emails instead of one when a record is updated

When i create a new record and update it my future class is sending two mails to user and after that when i update the same record then it sends one mail. Problem i need to send only one mail to user. ...
0
votes
1answer
86 views

Unable to use @future(callout=true) method in Apex class

1.Currently working on Apex with the flow to pass the API data. 2.If I use @future(callout=true) in apex it throws an error like below. Error: The only annotation that can be used with ...
1
vote
1answer
85 views

How to count email invocation in @future method ? Limit check after Test.stopTest is returning 0; [duplicate]

I can't understand why I am getting 0 from Limits.getEmailInvocations(); that is run after Test.stoptest(). The method which is sending emails is @future annotated and run from trigger handler on ...
2
votes
1answer
78 views

Max Number of callouts in future

Would like to clarify quick point as below statement in documentation is causing confusion. A single Apex transaction can make a maximum of 100 callouts to an HTTP request or an API call. So suppose ...
0
votes
0answers
61 views

How do I get the records from the database after they have been added using the "future" method?

I have a task in front of me: for the time period specified by the user, you need to get currency rates from a third-party service and display the results on the screen. I wrote the following code: //...
-2
votes
2answers
373 views

Apex error : You have uncommitted work pending. Please commit or rollback before calling out [duplicate]

Apex error : You have uncommitted work pending. Please commit or rollback before calling out. I get the above error when I try to make two http callout one after the other and store the result in ...
0
votes
1answer
83 views

Can @future be called in constructor of a class

Trailhead Link - https://trailhead.salesforce.com/content/learn/modules/asynchronous_apex/async_apex_future_methods#:~:text=Future%20methods%20won't%20necessarily,same%20order%20they%20are%20called.&...
0
votes
0answers
34 views

UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record. Case not saving: [duplicate]

I'm getting this error when trying to save a Case: Failed to invoke future method 'static void cloneCaseWithCaseProds(String, String, Set<Id>)' on class 'CTRL_Support_ProcessV2' for job id '...
-1
votes
1answer
59 views

Unable to add the Remote URL https://th-superbadge-apex.herokuapp.com/equipment

Hi am attempting Challenge2 : Synchronize Salesforce data with an external system of the Apex Specialist Superbadge but unable to add the below url to Remote Site settings https://th-superbadge-apex....
0
votes
0answers
21 views

Creating QuoteDocument with Apex behaves strangely in one org

In my class I have a future call to create a QuoteDocument. This works fine in all orgs (sandboxes and production) I have access to. But in the target org, it only creates an empty PDF (in a partial ...
0
votes
2answers
139 views

Update a record in future method with JSON data [closed]

From process builder getting record id and pass that in to apex. Apex class to update the record: public class BacktoQuantum { @InvocableMethod(label='getdata' description='Get data ...
0
votes
2answers
443 views

How can I update a record with information obtained from a @future callout?

I have a trigger which executes a callout on the Case object to create a resource in my backend. The callout returns the ID of the created resource, which should then be added to the Case the trigger ...
12
votes
2answers
2k views

Does queueing a future method count as DML?

We need to implement the following pattern at my org: callout to external data source if that callout takes too long (according to some configurable threshold), log an error (ie do some DML) if that ...
26
votes
5answers
34k views

Calling future method from Batch

I have a requirement where a future method need to be called from batch apex ,I came across various articles stating that a future method could not be called from the batch. Is there any alternate ...
0
votes
3answers
114 views

Multiple callout from future that is called from an InvocableMethod

I am having some difficulties to call multiple callouts from a future method which is calling from a Process Builder. I am getting the below error, System.CalloutException: You have uncommitted work ...
0
votes
1answer
126 views

How to achieve Asynchronous Apex with Aura Components? (NOT Callouts)

I have a working Aura Application with a requirement of showing heavy data inside of many lightning datatables based on the LoggedInUser. It works fine for majority of the users but for few, the data ...
0
votes
0answers
63 views

Executing a callout at the end of a chain of methods operating in @future context

I have a callout method that is executed as the last step of a long chain of methods when a record's status get changed to "completed". Early in this sequence, we have a method that we have ...
1
vote
0answers
31 views

Enqueuing chained queueable instances that trigger deployment jobs don't perform deployment

I've got problem with executing deployment jobs inside queueable instance. Background: Exchange rates data is divided between two endpoints a and b. That's why I need to make a callout twice. ...
0
votes
2answers
344 views

Using future method in triggers [closed]

Trigger batch size can be 200. If i call future method(callout=true) on every batch object, this will throw limits error or not? If it throw, how can i avoid this?
0
votes
1answer
224 views

Return from a future/Queueable callout

I have to do a callout, but before doing the callout I need to update the cases and use the values from the cases' fields in the request body and then do the callout. I cannot do DML before callout. ...
3
votes
3answers
490 views

How to mock System.isFuture()?

I am writing some tests and I have encounter a problem. In my main app I have the following logic: public static void main() { if (System.isFuture()) { System.debug('Is future'); // ...
-2
votes
1answer
51 views

How to solve read time out error in Apex callout?

Hi all and thanks for reading Got this code: public class SendingZabbixServices{ @future(callout = true) public static void zabbixDoPostFuture(String jsonString, String endpoint){ ...
3
votes
1answer
569 views

Is there a way to delete >1 Million records from a custom Big Object?

First thing that came to my mind was writing a Batch Apex to do this but I get this error. System.UnexpectedException: The requested operation is not supported by this SObject Deleting via Bulk API ...
1
vote
1answer
206 views

Metadata.Operations.enqueueDeployment Callback not allowing Callouts

I have a scenario where I am saving custom metadata for an external API configuration. I want to deploy all the metadata, then after the deploy job is done, make a callout to the API to verify the ...

1
2 3 4 5
9