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
1answer
33 views

You have uncommitted work pending. Please commit or rollback before calling out even if we put DML in future method

I know as per documentation, we cannot perform DML and then callouts from apex class. In my scenario, I have a callout then I am performing a DML which is placed inside a future method and again ...
0
votes
0answers
26 views

how to handle platform events from flow when received as a batch at once

I am creating a flow that uses an Apex action that calls multiple future methods in quick succession and publishes platform events for each of them when they are done. There is also another flow with ...
-1
votes
1answer
27 views

can i use multiple annotations in one apex class

can i use multiple annotations in single apex class; like i have the scenario of calling apex class from process builder which is having future method,suppose i am using setup objects and non-setup ...
0
votes
0answers
30 views

Alternative of Batch calling Future method

I've looked around to try to find some posts on this and there are many but none that address my specific question (that I could find). I am trying to call a @Future method inside a for loop in my ...
0
votes
2answers
32 views

Database.rollback() Method Not Working In Different Transaction?

I have created a very simple scenario where I'm creating a savepoint and trying to rolling back in future method. The behaviour is little confusing - I tried searching it over the net but I didn't ...
0
votes
2answers
31 views

Serialize and deserialize a list of Sobject for Future method

I am trying to pass a list Account records to a future method. Since future can only take primitives, I am planning to serialize and deserialize the Sobject. I tried below: List<Account> acList;...
2
votes
0answers
29 views

Unit test false positives because of future callout triggers

Background I have the following Apex class method which is called as a result of a trigger on a custom object, MySet: @future (callout=true) public static void exportMySet(string setId) { // do ...
0
votes
1answer
38 views

DML in @Future called from Trigger in Batch

I have a after insert trigger on an object that calls a @future method to do a callout to an external system. If the callout fails I want it to update the original object. I am batching up 100 at a ...
0
votes
1answer
45 views

How to make two callouts in sync?

From Trigger on inserting I am making a callout (from method1 of class A) i.e by using @future annotation and updating the field of the same object on which the trigger called, with the values ...
1
vote
1answer
77 views

How to force future method to wait until current thread finish?

I have an apex code which is called from an after trigger. The apex code calls a future method and sometimes the future method runs after the execution of the current thread and sometimes does not. I ...
0
votes
0answers
25 views

Bulkified trigger giving error on data import: Z4PAccountAddressTrigger: System.LimitException: Too many future calls: 51

I have a future call that gives me the error: System.LimitException: Too many future calls: 51, while importing multiple record with data loader. I did some googling on the limitations of future calls ...
0
votes
1answer
28 views

Accessing __history object data in future method

I have a future method inside which two methods are called @future public static void roundRobinAndMail(Id appId) { RoundRobinAssignment(appId); NMEF_EmailUtility.sendEmailFromTemplate(appId);...
0
votes
1answer
39 views

Mixed DML Error in Future method?

Whenever an user is inserted, I am assigning the license(UserPackageLicense) through Future method and also sending an email if we doesn't have enough license number. But I am getting the following ...
0
votes
0answers
67 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 ...
3
votes
0answers
54 views

Sporadic “Insufficient Privileges”

We sometimes receive screen shots from business users indicating they are seeing "Insufficient Privileges" errors. These errors come up in a variety of contexts, but they appear to mostly be ...
4
votes
1answer
152 views

Can Process Builder run @future methods?

We're hitting CPU Time Limit Exceeded issues with a class that's being called by a Process Builder. From the SF solutions page, it was noted that one fix for CPU Time Limit Exceeded is to make the ...
2
votes
1answer
178 views

How to check if future method has executed

in my apex code I need to do some calculation only when future method has executed I tried below code to check if future method has executed: public static void anotherMethod() { while('Completed' != ...
1
vote
1answer
48 views

How can I use queueable Apex instead of a future method with arguments?

I have an @future class, SubmitOnApproval which is called when an opportunity is approved. This class is below: public without sharing class SubmitOnApproval { @future public static void ...
1
vote
1answer
27 views

Capturing HttpResponse StatusCodes

I'm trying to capture a HttpResponse StatusCode in a @future method so I can then send it to an email to alert a dev of a possible issue and also alert the Salesfroce user of the error. I have found ...
2
votes
1answer
32 views

Need advise on callouts and inserting/updating new records from external system

We have an external application where few records gets updated or created on daily basis. We already implemented inbound calls to salesforce but it is scheduled for once a month. We need to schedule a ...
0
votes
1answer
44 views

Using HttpResponse in a seperate class from future

I have written a trigger that calls a class which contains a future method and I need to use the response to update a field. Is there anyway to capture the HttpResponse in a separate class? public ...
0
votes
1answer
34 views

Should I use a single callout with a list or mulitple callout for each Account?

I wanted to Bulkify my code to be able to update/create a long list of account for which I need to callout to my api. I know that I can't do more than 50 callouts per future methods. But using ...
4
votes
1answer
94 views

Method does not exist or incorrect signature: void send(System.HttpRequest) from the type System.HttpRequest

Currently stuck at trying to send a JSON structure through web services but keep receiving the error: Method does not exist or incorrect signature: void send(System.HttpRequest) from the type System....
1
vote
1answer
17 views

how quable solves the problem of having soobjcets in future mthods?

As per my knowledge both future and quable are async methods ,we don't know when they run,that's y we cant pass sobjects as parametrs in fuute methods(i read in future trailhead) because objects state ...
0
votes
0answers
32 views

Future Method cannot be called from another Future Method

I have a platform event trigger that calls a method in a class that is annotated with @future. This future method makes an external REST api call to get some data and updates values on the ...
-1
votes
1answer
58 views

Future method use response to make update on Opportunity object

I have a future method where I make an external REST api call which gets kicked off in an after update trigger on the Opportunity object. When the results come back, I deserialize the JSON and then ...
1
vote
2answers
99 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 ...
0
votes
0answers
18 views

Multiple sequential calls to API [duplicate]

I am having trouble figuring out a way to make multiple calls in order to an external API. The task is currently successfully working using javascript but I need it to work via apex for a large (200 -...
2
votes
0answers
123 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 ...
0
votes
1answer
22 views

How to Show Role Name And Assignedd Permission Name in History Object

Trigger: if (Trigger.isUpdate) { String jsonOldMap = JSON.serialize(Trigger.oldMap); String jsonNewMap = JSON.serialize(Trigger.newMap); AssignPermissionSetToUserHelper....
2
votes
1answer
139 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 ...
0
votes
2answers
69 views

Get ApexJobId from Future method

Is it possible to get the ApexJobId within the Future method apex code (or from the method its invoked from)? Use case - Our application is invoking multiple same future calls from within one apex ...
1
vote
1answer
77 views

Mass update process builder callout

After a record is updated I need to make a callout to an external api. At the moment I have invocable apex being called from process builder, which is calling a furture method with callout=true. ...
3
votes
1answer
199 views

Test Class - System.CalloutException: You have uncommitted work pending - Platform Event

I am using platform events and in one of the after triggers I am calling a method in a class where the method is annotated with @Future(Callout=true) In my test method below I am doing some DML to ...
1
vote
3answers
46 views

Future method completes first before the queueable

My scenario is: A future method is on a queueable class. Queueable job comes first before the Future job in the Apex Jobs. Upon checking the completion date(time), the future method is completing ...
0
votes
1answer
151 views

How could I get values from a global declared map, inside a @future method?

I'm facing an issue of accessing objects, That is the first time I'm trying to use Global variables on APEX ; I got a @future main method that calls two methods, In the first method I would like to ...
1
vote
1answer
65 views

Ordering @future method

is there any functionality in the salesforce that we can set order of the future methods? someone just told me that we can do that and i was looking for that but could not find any solution. ...
0
votes
1answer
50 views

Insert 16k Records in one Transaction cant use Batch Classes / Future call give me CPU Limit Exceed

Please help me this. I have a call to action in salesforce visual force page, that insert 16k records. But as per salesforce Limitation, we can only update 10k Records in a DML Transaction I divide ...
2
votes
1answer
362 views

New Picklist Values added via Metadata API stay inactive

I am using the Metadata API wrapper from https://github.com/financialforcedev/apex-mdapi to dynamically add picklist values to an existing field. @Future(Callout=true) private static void ...
0
votes
0answers
110 views

Error on a Future Method, But I Don't See How It's Being Called to Begin With

The only awareness I have of the error is from this email notification : Apex script unhandled exception by user/organization: 0051H000009g2Fv/00D1H000000NPnk Failed to invoke future method 'public ...
1
vote
3answers
78 views

Trigger calling future method

I have inherited an after insert lead trigger that calls a future method. Based on the response returned by this method, it inserts records in an object. Lets call this object -LeadCopy__c. Lead --&...
-2
votes
1answer
157 views

System.AsyncException in trigger

Trigger Snippets: if (JIRA.currentUserIsNotJiraAgent()) { if(System.isFuture() == false || System.isBatch() == false || System.isScheduled() == false) { //Check, If Not in any Async Apex ...
5
votes
2answers
99 views

How to disable asynchronous jobs so that they cannot update data

There will be a data export happening from our org for large number of objects and records using a cloud based ETL tool. We have a business scenario where we need to make sure that there is no data ...
0
votes
1answer
122 views

How to elegantly handle asynchronous pushes from Salesforce to external system via a REST API [closed]

The key word in the question is elegantly; I'm an experienced developer familiar with the mechanics of asynchronous programming, REST APIs, database triggers, programming idioms and design patterns. ...
0
votes
2answers
322 views

How to get the response data in @future(Callout=true)

I need to catch the response of a callout method and insert it into a database. But what the problem is, the callout method called from a trigger. Therefore, I have to add the annotation @future(...
0
votes
1answer
338 views

How to call future method from lighting controller

Is there a way to call future method from lightning controller? @auraEnabled and @future can co-exist together? example: Class ABC{ @auraEnabled public static void callfromFuture() { //...
0
votes
1answer
227 views

Any real time scenario when we will need to call future method from batch class? [closed]

I am trying to understand if there is any real time scenario when we will need to call future method from batch class ? Can anyone please help me ? Thanks
0
votes
3answers
54 views

Too many futurecalls: 51 [duplicate]

I got the following email: Sandbox: Developer script exception from ContactTrigger: System.LimitException: Too many futurecalls: 51 Important addition: I do not see that mentioned 50 calls were ...
2
votes
1answer
119 views

Future method is not invoked from PostInstall script

I'm trying to create a future method that makes a callout, and for some reason it's not invoked when the script is done. postInstallScript.cls: global class postInstallScript implements system....
0
votes
1answer
66 views

How to Deserialize the Trigger old & newMaps in JSON

I'm trying to pass the old & newmaps as arguments to a future method using JSON method. I see the below error when it tries to deserialize the data. reference-Passing SObjects to Future |...

1
2 3 4 5
8