A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

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
3
votes
3answers
2k views

How to test schedulable job with future method?

I have daily job that makes callouts and updates some records. There is @future method invocation in execute() method. I have created test according to this guide: https://developer.salesforce.com/...
0
votes
1answer
3k views

Getting error unexpected syntax: 'mismatched input 'if' expecting RCURLY'

This is my class and I am getting this error. I want to update the same Project record with another status. I wrote the below if in future, which compiled successfully, However, as the records are ...
4
votes
1answer
103 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 ...
3
votes
1answer
2k 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 ...
2
votes
1answer
94 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
42 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
23 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 ...
0
votes
1answer
40 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 ...
2
votes
1answer
30 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 ...
1
vote
1answer
535 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 ...
0
votes
1answer
33 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
70 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 ...
13
votes
1answer
6k views

Difference between Queueable apex and future method

I understand that you could pass collection of Sobjects to Queueable apex classes but not to future methods where we're restricted to only primitive collections. The reason it's not done for future ...
0
votes
0answers
31 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 ...
8
votes
3answers
7k views

how to test a future method which makes callouts?

I am practising the Integration workbook provided by salesforce. In tutorial#2 there's a class which makes future callouts to a Heroku app.This class is called by an after update trigger. Callout ...
-1
votes
1answer
46 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
46 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 ...
2
votes
0answers
89 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 ...
3
votes
1answer
581 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 ...
5
votes
3answers
6k views

Prevent trigger from running in single test

Ok so I have a fairly complex scenario I need to test... I have a Trigger on a MyObject__c that creates PermissionSetAssigments when MyObject__c is inserted. Because PS Assignments are system ...
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 -...
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....
1
vote
1answer
692 views

ChronJob Table Locked, Preventing Active Job from Rescheduling Itself

I have a scheduled job, which updates Setup and non-Setup objects. The scheduled job performs immediate changes on the non-Setup objects, and (in same run) executes a method using the @future ...
0
votes
1answer
630 views

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY error in production

I got following error in production. Apex script unhandled exception by user/organization: 00580000005FYRy/00D80000000PQ16 Failed to invoke future method 'public static void updateSubs(List)' on ...
2
votes
1answer
98 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
41 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
58 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
167 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 ...
0
votes
1answer
83 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
3answers
45 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 ...
1
vote
1answer
45 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
48 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
259 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
1answer
92 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
0answers
67 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
65 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 --&...
5
votes
2answers
92 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 ...
4
votes
1answer
1k views

Future Method to Trigger to Future Method

I was attempting to call a future callout method from a trigger and am getting the error that a future method can not be called from a future or batch method. The trigger is being called on insert of ...
-2
votes
1answer
84 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 ...
0
votes
2answers
229 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(...
7
votes
2answers
6k views

First error: [UNKNOWN_EXCEPTION] ConcurrentPerOrgLongTxn Limit exceeded

We are currently facing a Salesforce platform error I have never seen before; First error: [UNKNOWN_EXCEPTION] ConcurrentPerOrgLongTxn Limit exceeded This happens both when logging into the API ...
0
votes
1answer
263 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
167 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
52 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
102 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
483 views

Apex Test Class Assert for Void?

How can I build an Apex test class to validate a class method that has a @future HTTPRequest setting? The @future method returns a void, but I can't test a void value with a System.assert[Not]Equals......
3
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
51 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 |...
2
votes
2answers
609 views

Is there a limit on the maximum number of future jobs queued in an org?

I know there are certain limits with batch jobs, queued jobs, etc., but what about future jobs?