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
1answer
70 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
33 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
39 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
361 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
26 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. ...
1
vote
1answer
320 views

Soap Callout From Trigger - how to get the response

I am struggling with a weird issue. I have a Soap webservice fired from a after insert/ after update Trigger. i made my function @future to be able to make the call but the response that i have is my ...
0
votes
1answer
41 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 ...
11
votes
1answer
5k 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 ...
2
votes
1answer
84 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
70 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
36 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 ...
3
votes
1answer
547 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
1answer
584 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
591 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 ...
1
vote
3answers
46 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
82 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 ...
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 ...
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
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
47 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
76 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
5k 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
108 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
63 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
45 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
66 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
400 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
1k 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
35 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
399 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?
5
votes
2answers
5k views

Call Queueable from future method

I have a use-case where I need to execute some logic in async mode and I found that using Queueable Interface I can achieve that. But when I am trying to the use the Queuable Interface, some issues ...
0
votes
1answer
21 views

How to make a call out from batch which (batch) get schedule from trigger?

I'm trying to call a method which do an api call. But I'm getting an error because this method get call through the process ran by batch and this is getting schedule from trigger. So even if i ...
1
vote
1answer
75 views
0
votes
1answer
96 views

How to do a dependent callout from a future callout

How do I send a future callout to an external system inserting an parent object and as soon as I get the response back with an external id send another callout with a child object to an external ...
0
votes
1answer
24 views

How to notify users after the last future method completes?

From the Visualforce Page, we call a method that inserts a user record and then subsequently calls three future methods to complete the user onboarding process. insert user record Call 1st future ...
0
votes
0answers
52 views

@future method not getting called from catch block

I am calling a webservice (synchronous) and in case of CalloutException, I'm trying to create an error log in a custom object. The problem is, the record insertion is happening in a future method and ...
0
votes
0answers
87 views

Run Queueable as sequence

Good day Everyone, I have a trigger that will call a Queueable. The process looks like this : Trigger : for(User userData : Trigger.new) { if(Limits.getLimitQueueableJobs() - Limits.getQueueableJobs(...
1
vote
1answer
61 views

Is it possible to call a future static callout method from a scheduler

I have a static callout which i want to schedule every 5 minutes. How would i approach this I have tried the following but the the incorrect signature error: Callout public class or_service { @...
1
vote
1answer
296 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 ...
-1
votes
2answers
422 views

Future method cannot be called from a future or batch method

I am calling an Apex Future method from Process builder. This is working fine when the Process Builder condition is "only when a record is created". But when I change the condition to "when a record ...
1
vote
0answers
518 views

Trigger not executing @future method for bulk transactions

I'm wondering can anyone help? I have an after insert, after update trigger on Contact that calls an @future method in a helper class to create portal users for contacts. In an attempt to prevent ...
1
vote
2answers
595 views

Trigger to make @future callout to the Data.com match API

My company uses data.com premium. We want to create a trigger that will update a lead based on company information since the out-of-the-box functionality only matches based on the lead. (contact). I ...
2
votes
1answer
1k 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 ...
4
votes
3answers
691 views

Confused by CalloutException

I have a trigger on Account and Opportunity - both do a callout to the Google Geocoding API and then update itself using a future method. Now I also want to send an email before the update if certain ...
0
votes
1answer
35 views

Update record page after record is updated by calling external API

I have trigger on contact which validates phone by calling external API. To be able to call the the API from trigger, I'm using future annotation. The callout method writes the result to custom field ...
10
votes
2answers
4k views

How to work around the 100 callout limitation?

We need to have the ability to make more than 2999 callouts to a REST service. Currently, we are getting a raised exception when the number of callouts is more than current limit for callouts. Thus, ...
2
votes
1answer
267 views

Platform Events + Process Builder + Apex with @future method

I'm running into an issue with too many future calls when handling Platform Events with a Process Builder that uses an invocable Apex class. Basic setup is 2 processes: The first publishes an event ...
3
votes
1answer
463 views

Custom Logging and Future Methods

I have been reading up on the custom logging, DML, and exceptions but haven't seen anything that talks about @Future methods and exceptions. I have two scenarios: A Button is clicked on a Lead, ...
0
votes
2answers
222 views

Calling a Class from a Trigger (calls external service)

I am at my wits end with Future Methods coding and would be very grateful for a working example. I've been reading through the Future Methods documentation here: https://developer.salesforce.com/docs/...
0
votes
2answers
273 views

Future methods do not support parameter type of Exception

I'm stuck at this error "Future methods do not support parameter type of Exception". Is there any workaround for this error?