We changed our privacy policy. Read more.

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.

68 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
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....
4
votes
0answers
118 views

compiling error during runtime for class that compiles fine

I'm getting the following error (below) while executing a future call. The mentioned class compiles and saves fine upon retesting. Any idea why this would be occurring at runtime? It seems to work ...
4
votes
0answers
167 views

Calling APEX out of JavaScript the APEX-API Version is ignored

I run in an issue with calling APEX out of JavaScript, when i call my APEX class, the class is executed with API-version 34.0, but in the metadata of this class is the API-version set to 27.0. I need ...
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 ...
3
votes
0answers
518 views

Executing multiple callouts from a future method

I have a problem when I try to execute multiple callout from a method of an Apex Class. The method code is the following: @future(callout=true) public static HttpResponse makeCallout(){ List<...
3
votes
0answers
137 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 ...
3
votes
0answers
106 views

Failures during bulk insertion of records not executing @Future methods

I have a requirement to populate the GeoCode whenever the Account records are inserted or updated. I have written after insert, after update trigger to fire a geolocation google API it works perfectly ...
3
votes
0answers
755 views

Future callouts when trigger fires from batch job

I have a batch job that goes through a list of a custom objects and updates certain field. This is working correctly. The custom object is part of a managed packaged. On the custom object is a ...
3
votes
1answer
733 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 ...
2
votes
0answers
54 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 ...
2
votes
0answers
33 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 ...
2
votes
0answers
358 views

All attempts to execute message failed, message was put on dead message queue

I have a process that is chaining Queuables using a future method similar to this: public class MyQueuable implements Queueable{ public virtual void execute(QueueableContext context){ //do ...
2
votes
0answers
72 views

How to resolve the problem of refreshing standard page multiple times until callout completes?

We are using opportunity custom button to populate the value of a field based on the response form future callout. In order to receive the value we had to keep refreshing the opportunity page until ...
2
votes
0answers
700 views

ConcurrentPerOrgApex Limit exceeded

We are calling Queueable Interface from trigger to make multiple callouts to external systems. The number of callout from Queueable class is 50 as the other system can process only one record at a ...
2
votes
0answers
493 views

Test Method for callout in Future method

I have a trigger on Account. On Account insert, I am sending a callout through future method. I am trying to write a test class for this but I am getting either of these two errors - 1) You have ...
1
vote
0answers
30 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. ...
1
vote
1answer
237 views

Unit Testing code with Database.savepoint and a queuable apex or future callout

Here is the scenario I'm running into. Is there any way to unit test a rollback where dml is performed followed by an async process? I understand that wrapping savepoint in if(!Test.isRunning()) is ...
1
vote
0answers
292 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
vote
0answers
427 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
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
0answers
367 views

User Automation and Future Method and Permissions Issue

I am stumped on a problem and was hoping someone could spur some thought. I have two users who have different profiles. The System Admin profile is able to get through a Future Method and a ...
1
vote
1answer
169 views

Creating user's with batch apex which will invoke a trigger and a future method

I have a trigger on user object which runs on the creation of new users of a particular profile and also has a future method called for assigning user some id's So my doubt is if I insert the user's ...
1
vote
0answers
119 views

JSON Post via Apex - PKIX path Building Failed - What am I doing wrong?

This is my first time attempting a JSON POST and I trust your collective judgement. I would appreciate if someone could tell me if I am approaching this correctly or not. I didn't receive any compile ...
1
vote
0answers
841 views

How to pass the session ID as a argument to a future method?

I have a trigger which calls a future method and the future method uses the ToolingAPI to execute something.But I dont know how to pass the session ID to the future method from the trigger. ...
1
vote
0answers
196 views

Turn on User TraceFlag from APEX Class

I am currently having difficulty to add a new traceflag from APEX Trigger or Class. Now, I've tried to use tooling API and using rest API call to activate a traceflag whenever new custom object gets ...
1
vote
0answers
10k views

Webservice Callout Exception: IO Exception: Read timed out

I have Salesforce trigger that triggers either a future method or batch job that does call outs to a SOAP webservice. I am randomly getting "(IO Exception: Read timed out)" exception. When the ...
1
vote
0answers
606 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
0answers
264 views

Making apex callout after sendEmail() in Batch apex

This is related to question, Processing callouts from Batch, but is specific to Emails operations. We are sending contents of email in apex callouts. The content contain merge fields, which is not ...
1
vote
0answers
5k views

Apex Callout Exception: IO Exception: Read timed out

I have Salesforce trigger that triggers either a future method or batch job that does call outs to a SOAP webservice. IF the number of call outs I need to make is one then future method is triggered. ...
0
votes
0answers
53 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 ...
0
votes
1answer
43 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 ...
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 ...
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: //...
0
votes
1answer
35 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 ...
0
votes
0answers
16 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
1answer
86 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
62 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 ...
0
votes
1answer
136 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. ...
0
votes
0answers
166 views

Call a @Future method with the Process Builder

I am attempting to call a class with a @Future method by using Process Builder. In order to do this I believe I need to initially call a class with an @InvocableMethod to in-turn call that @Future ...
0
votes
0answers
36 views

Salesforce to another SF org: insert Lead + Attachments

I want to send a post request from SFDC org to other to insert Lead in other org along with it's attachments(Selected Attachments) I had sent all the parameters of lead and attachments in single ...
0
votes
0answers
64 views

How do I troubleshoot @future jobs that simply vanishes?

I am working in an environment where some @future jobs seems to vanish. It's a quite complex org so I'll try to explain as clearly and detailed as possible. When a lead changes Status a new record ...
0
votes
0answers
292 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
0answers
35 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
291 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
577 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 ...
0
votes
1answer
45 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 ...
0
votes
1answer
27 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....
0
votes
0answers
438 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 ...
0
votes
0answers
345 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
60 views

Did not receive exception email in production

We usually get exception emails to our admin from the production. I have a asynchronous code running in production @future public static void processRecords(String FIMCJSONRec) { ...