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
2
votes
1answer
428 views

System.CalloutException on Production, but not on Sandbox

I am facing weird behavior of test running. I have two sandboxes and production. One sandbox is where development is done, second to test. I developed class and deployed it to second sandbox, run all ...
2
votes
1answer
5k views

System.LimitException: Too many future calls: 1 in batch finish [duplicate]

I have actually a batch on user, where user are activated or deactivated based on a criteria. In each execute I update my set of users, which in turn launch an @future method to recalculate the role ...
2
votes
1answer
456 views

@remoteaction or @future

I have a trigger which run on insert of a parent record. The working for trigger is like when parent is inserted all the child related to parent get inserted and when child get inserted all the grand ...
2
votes
2answers
238 views

During deployment, Test Class for trigger of @future method with callout returning "Uncommited work pending error"

So I'm familiar with the error System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out but I'm stumped with this one! I have a call with a @future ...
2
votes
1answer
2k views

How to pass SObject in future method?

I am a beginner in programming world. I know the reason for error that we cannot use sobject as parameters in future method. Checking on forums i came to know that we can use set and then query record ...
2
votes
1answer
2k views

Can a schedule be executed from future method?

One cannot execute a batch from a future annotated method. It is also impossible to have a trigger reacting to changes in future calling a batch. I cannot find if it is possible to execute a schedule ...
2
votes
1answer
118 views

Max Number of callouts in future

Would like to clarify quick point as below statement in documentation is causing confusion. A single Apex transaction can make a maximum of 100 callouts to an HTTP request or an API call. So suppose ...
2
votes
1answer
94 views

The way to execute http callout from apex

I'm a new in integration and I try to make a simple integration, but i'm stuck. Scenario is simple: When record updates or creates, need to pass record data to external system. So I create a class ...
2
votes
1answer
64 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 ...
2
votes
1answer
20 views

How do I expose background tasks to end users?

My users sometimes kick off some long-running background processes (e.g., add 150 records that look like this template, run this batch process, etc.). Right now, if those processes fail, they are not ...
2
votes
1answer
3k 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 ...
2
votes
1answer
114 views

Return a response after calling a REST point created on salesforce, while the REST point is calling a @future method

I have crated a RESTful endpoint on my sandbox. When it is called with the proper input it creates a new contact and then decorates a custom response class I created for that purpose and at the end it ...
2
votes
1answer
3k views

“System.CalloutException: IO Exception: java.security.cert.CertificateException: No subject alternative names present”

I'm facing “System.CalloutException: IO Exception: java.security.cert.CertificateException: No subject alternative names present” error when I try to make a callout to an external webservice. Problem ...
2
votes
1answer
2k views

Future Method: Too many future calls : 51

Working on a future method to post values to external web service. But since there is a limit of 50 callouts per invocation, I am getting error "Too many future calls : 51". Cases are loaded into ...
2
votes
1answer
2k views

update records through a @future callout method inside a before/after update trigger fires

I have a trigger that fires when the address has changed on a record. I make a callout to Google API to gain the longitude and latitude information that I then want to put inside of my record. When ...
2
votes
2answers
2k views

REST API calls to 3rd Party (Pardot), multiple @future callouts

Setup: Pardot (3rd Party services I'm using) requires you to request an API_Key by submitting your email, password, and user_key so that you can then use the api_key with the user_key to do any API ...
2
votes
2answers
1k views

Code in a @future method not working

I am trying to write a trigger that will transfer attachments from a Task object to the related Opportunity object from emails & attachments using Salesforce for Outlook. I have the basic trigger ...
2
votes
1answer
142 views

How can an object with an ID disapear?

I have an error logging object that stores errors. In most cases, when I call my method to create a new Error Log record, it properly creates and inserts the record. When I call the error logging ...
2
votes
0answers
56 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
1answer
209 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. ...
2
votes
0answers
1k views

Testing a queueable class containing a future callout [duplicate]

I have a queueable class that makes callouts (@future(callout=true)) in the execute method. When I manually test this, everything works correctly. But when I set up my test class, it gives me the "You ...
2
votes
0answers
376 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
708 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
2answers
1k views

First error: Too many query rows: 50001

I have a read query in a batch class which in orgs with a lot of data can bring back over 50,000 records and violate the governor limit. I am trying to hard delete records. I am using the class below ...
1
vote
1answer
436 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 ...
1
vote
1answer
851 views

Call a non future method in future

I have a non future method that I use for before insert in criteria A, how can I use this method to a future method without copying the method and adding @future because I also need this for a ...
1
vote
2answers
636 views

Trigger How to stop Database.executeBatch cannot be callled from a future method error

I'm calling a trigger after insert and after update, which is calling an Apex Class which hits an endpoint. The triggers are working as expected and firing to an endpoint when a checkbox is selected ...
1
vote
1answer
2k views

Not able to call @future from @future

I am trying to call @future method from trigger and got CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY Error, because of update operation within the @future method. Class and triggers given below. Error ...
1
vote
1answer
65 views

System Assertion not returning the right result in an @Future method

I have a class that updates leads and sends emails to the Lead owners, this part works just fine. Now that I'm writing the Test class, in my test the lead I create doesn't get updated. Why could that ...
1
vote
1answer
422 views

Why Inserting User must happen in a future method?

I found this statement "Inserting a user with a non-null role must be done in a separate thread from DML operations on other sObjects" "here" and below is the code: public class MixedDMLFuture { ...
1
vote
2answers
40 views

Why there is explicit provision for not allowing callout from future methods using (callout=false) , if by default it doesn't allow?

Like with 'without sharing' and 'with sharing' for class, 'without sharing' has clear use in case you want to explicitly turn off sharing rule enforcement when a class acquires sharing rules when it ...
1
vote
1answer
868 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 ...
1
vote
1answer
569 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
2answers
1k 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(...
1
vote
2answers
93 views

Future Method Invokation

I know we can't call future method from a batch class or from any future methods. "Future method cannot be called from a future or batch method" I have an Account trigger which has a lot of future ...
1
vote
1answer
821 views

Disable Future method from running twice

I have a future method that i call in afterInsert and AfterUpdate Triggers. i want to disable the running of the AfterUpdate call if AfterInsert ran before it, if i do not disable it i get the ...
1
vote
1answer
92 views

Dealing with @Future Calls

I have recently enabled a connection between the data from Google Analytics to Salesforce. In order to do this I am making a http request from salesforce to GA using an access token I receive from ...
1
vote
1answer
3k views

Mock Unit Test for a REST API callout

After attending DF14 I have a fairly solid understanding of the HttpCalloutMock() when unit testing for REST callouts, but I'm having trouble implementing unit testing for the first time. The ...
1
vote
3answers
302 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
101 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
418 views

how to send trigger data to future method and change it based on response from callout

My triger code is trigger sendMessage on Message__c (before insert) { //retrieve contact info of selected contact-------------------- sObject contact = [Select Name, Phone, Title, ...
1
vote
1answer
3k views

System.DmlException: Insert failed: MIXED_DML_OPERATION, DML

So I have some code below that causes the error: System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after ...
1
vote
2answers
119 views

Understanding persistence in @future call

I was reading about using @future and the asynchronous process and I wanted to get clarification on persistence. For example, if I have an @future method that makes a call to an endpoint in which I'...
1
vote
1answer
845 views

Can a future method conflict with a queuable method?

My custom code is executed using a queuable class. Sometime it runs perfectly, other times it gives this error: Failed to update list. Error: System.DmlException: Update failed. First exception ...
1
vote
1answer
25 views

Execute queue in certain hours only

How can I modify this class to execute only within office hours? public with sharing class AddLeadQueue { public void AddLeadQueue() { System.debug('loaded'); } @future (callout ...
1
vote
1answer
337 views

Handling Asynchronous Responses from Box.com

I'm using the Box Toolkit for Salesforce. As you know, in Apex I have to make asynchronous calls to Box. My problem is that sometimes when am performing multiple operation, such as creating a folder,...
1
vote
1answer
966 views

How to test @future methods [duplicate]

I've the following services: public with sharing class LibraryService { public static void remove(String jsonString) { Library__c library = [ SELECT Id, ilms__Library_Name__c FROM ...

1 2 3
4
5
9