Skip to main content

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
0 answers
16 views

How to write test class for future httpcallout which is written [duplicate]

I have a class when QuoteAwsAccountId Object is created or AwsAccountId value inside the QuoteAwsAccountd object which is a string then it should make a get call to external api using Named ...
3 votes
1 answer
6k 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 ...
0 votes
1 answer
52 views

System.QueryException: Record Currently Unavailable

Im getting the following error: caused by: System.QueryException: Record Currently Unavailable: The record you are attempting to edit, or one of its related records, is currently being modified by ...
1 vote
0 answers
56 views

Unexplained pause in Apex transaction

Inside a future method we are inserting some records and we've come across a problem when Apex takes about 4.5 seconds delay between 'Executes all before triggers' and 'Runs most system validation ...
0 votes
0 answers
26 views

Web callout 1 record at a time - Future vs Platform events

So I have a situation where the third party web callout can only process record at a time. From SF perspective, if I would like to mass process records and send them to the external web service. I am ...
1 vote
2 answers
42 views

I want to write a unit test that can assert an enqueued job called a specific @Future function

To start, let's say I have this simple unit test: @isTest public static void shouldCallFutureMethod() { Test.startTest(); System.enqueueJob(myQueueableJob); Test.stopTest(); } Given ...
4 votes
1 answer
975 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
1 answer
2k views

System.CalloutException: Received fatal alert: handshake_failure

I am trying to do a salesforce integration US Census. When I run the below code I am getting following error "System.CalloutException: Received fatal alert: handshake_failure" I have a self signed ...
5 votes
2 answers
2k 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....
26 votes
6 answers
38k 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 ...
1 vote
1 answer
66 views

I have a trigger that makes callout to external system in a future(callout=true) but does not run immediately. Where is this callout queued?

@future(callout=true) public static void makeCallout() { System.debug('Hello World-1!'); // Instantiate a new Http object Http h = new Http(); String endpoint = 'https://******...
4 votes
1 answer
4k 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
1 answer
63 views

Do queueables have their own governor limits?

I have a class that makes consecutive API calls. I set the timeout to the maximum value allowed by Salesforce (120 seconds) however sometimes these are timing out because of the API taking way too ...
0 votes
0 answers
21 views

Manager Id is not updating whenver the user is deactivated using apex trigger [duplicate]

My implementation: trigger userTrigger on User (after update) { Switch on Trigger.OperationType { when AFTER_UPDATE { userHandler.checkUser(Trigger....
10 votes
3 answers
1k views

Guarantee only a single asynchronous job runs at a time

This is a bit of an odd one. We are interacting with an external system that does not support concurrency due to a bug which they are struggling to fix. We perform a HTTP callout, the callout takes ...
0 votes
0 answers
23 views

Wrote a Future method where Testcoverage is not 100% [duplicate]

Testcoverage class : @isTest public class AccountCalcultorTest { @isTest public static void contactcalculatorTest(){ List<Account> accAdd = new List<Account>(); ...
1 vote
1 answer
80 views

List of Strings is empty in @Future-method

So I have a list of Strings which is populated with Ids (in form of Strings) in the batchProcessSchedules() method. By reaching the limit (size) it will pass this list, together with another list and ...
6 votes
3 answers
11k views

Diference between @future (callout= true / false)

I don't understand the difference between: @future (callout= true) and @future (callout= false) I have read the documentation, but I don't understand where to use one or the other.
3 votes
2 answers
551 views

Using Apex, how do I monitor the daily @future limits?

This support article indicates that I have a limit of 250k @future methods per day. However, I can't find the corresponding Limit class function to monitor this limit. I've tried: System.debug(Limits....
0 votes
0 answers
109 views

I have two Queueable Jobs running in a transaction how to resolve it

On Order Product object I have an integration with a 3rd party system, which sends data the 3rd party whenever the Order Product through Queueable class. Now I am trying to insert a set of records to ...
1 vote
2 answers
2k 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
0 answers
48 views

Test class for @future method called by trigger not working (Methods defined as TestMethod do not support Web service callouts) [duplicate]

I have a trigger on Account that makes a call to an apex class: trigger AccountAddressTrigger on Account (after insert) { Id patientAccountRecordTypeId = [SELECT Id, RecordType.DeveloperName FROM ...
0 votes
0 answers
83 views

@Future method is not getting called. No logs, no exception no errors. When records are inserted through REST API call from an external system

Orders custom object have a lookup on Contact. Each Order will have a corresponding contact. A contact can have multiple orders. When an order's is inserted through Salesforce or any tools for ...
0 votes
1 answer
118 views

Change Data Capture (Async Apex Trigger) vs @future method in Trigger

What is the difference between using the Async Apex trigger and @future methods? Why use Async Apex Trigger when we have @future method to separate the thread from the main Trigger? The only ...
0 votes
1 answer
133 views

'uncommitted work pending' even when all DML statements have been deactivated

Our system is pretty complex with DML statements, call-outs and future methods everywhere. After adding some more functionality, I ran into the dreaded 'uncommitted work pending' error. It had been a ...
3 votes
2 answers
2k views

Why we are allowed to pass sObject in queueable?

I am having a small doubt, and want to have some inputs on that. For future methods, we are not allowed to have sObjects as method params/arguments. and the reason in documentation is stated as ...
-1 votes
1 answer
378 views

I need to get the data in a trigger after an api callout with @Future methode

I need to get the fields from the api and update them in the salesforce object , so i need to callout an api . Here is my trigger trigger getEntrepriseData on Account (before insert,before update) { ...
0 votes
1 answer
124 views

How can I convert normal triggerHandler Method to Future method?

Im learning about Future methods so wanted to covert my triggerHandler method to Future method...where Im trying to insert contact on every user insert. but im getting an issue called "Future ...
-3 votes
2 answers
5k 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
0 answers
142 views

Question on beforeUpdate or afterUpdate trigger in Salesforce

I have some doubts on whether I should be using a beforeUpdate or an afterTrigger for the scenario enlisted below. Any pointers would be very helpful. Thanks in advance. I have a custom object ABC ...
1 vote
1 answer
180 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) ...
-1 votes
1 answer
37 views

Getting Error in This Test Class

@isTest private class LeadUpdateTriggerHandlerTest { @isTest static void testHandleUpdate() { // Create test data Lead testLead = new Lead(FirstName = 'Test'...
0 votes
0 answers
15 views

When will Aysnc method or Class will execute? [duplicate]

We have a case object subject field. When the case is created, Trigger fires and update the subject, then flows fire to update subject again..Now i have a future method or Queueable class or batch ...
3 votes
2 answers
3k views

Can flow commit changes prior to invoking a method?

I'm trying to get some advanced architecture setup for my company, but I'm running into an issue with my design; looking for help. I'm attempting to execute an API call from Flow, but I'm getting the ...
0 votes
1 answer
529 views

After Update and Insert Trigger with Future Method Causing DMLException

I'm trying to update a field on the account field with a trigger using after insert and update. I am using a future method to make a callout to a rest API to get the rate of BTC in USD. My issue is ...
8 votes
1 answer
2k views

Test execution order issues with Queueable and @future method

Test code: * Test.startTest(); * System.enqueueJob(new MyJob()); * Test.stopTest(); * System.debug('Quering record for assertion'); Expected Queueable job execution: * Job Start * Query records * ...
0 votes
1 answer
110 views

Reload Visualforce Page after Future Method

I have a visualforce page that creates a record, and then assigns a permission set to the User and updates some of the fields on the user. The update for the Permission Set Assignment needs to be a ...
3 votes
2 answers
5k views

Asynchronous getContent hit org.apache.commons.httpclient.RedirectException: Maximum redirects (100) exceeded

we're having an issue with getContent() in asynchronous context, and I just can't find any way to work around it... We're exposing invocable Apex in our managed package, and one of them allow our ...
0 votes
1 answer
122 views

"Chaining" @future calls

How is the chaining of future call achieved in example from Dan Appleman book http://advancedapex.com/samplecode/ ? I am trying to insert 200/220 records and see that only one future is forced. ...
1 vote
3 answers
640 views

Does Queueable Apex guarantee preventing deadlocks if implemented correctly?

I just want to confirm my understanding is correct of whether or not Queueable Apex will alleviate an issue I am having with @future methods. Right now, in my org's account trigger handler class, we ...
4 votes
0 answers
507 views

Blank PDF using getContentAsPDF in future method

I am having an issue in production with a specific Profile (a clone of the System Administrator) that generates Invoices via a @future call resulting in a blank PDF creation. Below is a simplified ...
3 votes
2 answers
1k views

Why can't we use non-primitive data types in future methods?

Why can we use non-primitive data types in Queueable and not in Future methods when both are async processes? The reason that salesforce has documented is - 'The reason why sObjects can’t be passed as ...
0 votes
1 answer
40 views

Can future() methods be chained in a similar manner to batch jobs, to manage sequencing?

I have a trigger that hands off its trigger context to a queueable class, so that I can them make outbound REST calls to initiate campaigns. Trigger > queueable > processorClass with @future ...
1 vote
1 answer
88 views

Too many DML statemnts 151 in Future apex

I am getting Too many DML statemnts 151 IN MY aPEX JOB SECTION Due to this code public class LeadFuture_TradingAccUpdate { @future(callout=true) public static void updateTradingAccounts(Set&...
1 vote
1 answer
3k 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
1 answer
234 views

Loosely coupled Queueable framework

Edit: Sorry for the confusion! I’m trying to use this generic framework I mentioned below the error message I’m getting from my code which is calling a standard queueable class. So, my question: I ...
0 votes
1 answer
3k views

Future methods in flow actions

I've two flow actions which both make HTTP callouts. The second action depends on the output of the first. However, since future methods don't return a value, I'm unable to use the second action in ...
0 votes
1 answer
312 views

To block the creation of Account record based on apex callout response

My requirement is I need to block the creation of Account records based on apex future callout response TriggerCode trigger AccountTrigger on Account (before insert) { Set<Id> accLst = new ...
-1 votes
1 answer
276 views

Multiple Web Callouts In Scheduled Apex

I'm trying to get some additional information on specific phone numbers in my database using web callouts. I won't hit the governor limits as it's going to be less than 100 numbers per day. I'm also ...
0 votes
2 answers
4k views

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

I'm getting the below error while running the test class. Can anyone help on this please? Error : System.DmlException: Insert failed. First exception on row 0 with id a057h000002BqVUAA0; first error: ...

1
2 3 4 5
10