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
370 views

Future method rollback

I have a System.LimitException problem: Apex CPU time limit exceeded in Apex, and I have therefore modified a synchronous functionality in asynchronous functionality by changing the method in @future. ...
1
vote
1answer
167 views

Error while opening PDF document created through Future method

I have a webservice class 'restExample' which first performs DML operations and then calls a future method 'createDocument()'. This method will create PDF document. One important point: Running user ...
0
votes
0answers
370 views

Insert New Picklist value with record type in MetaData Service [duplicate]

Using MetaData API, am able to insert the value in Picklist field in apex code but it is not available for any record type. I am finding hard to expose the value to record type. Here is my code, ...
1
vote
2answers
33 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 ...
10
votes
2answers
312 views

Guarantee only a single asynchronous job runs at a time

This is a bit of an odd one. We are interacting with an external system that does not support concurrency due to a bug which they are struggling to fix. We perform a HTTP callout, the callout takes ...
3
votes
2answers
886 views

Queueable - Callout not allowed from this future method

I am using a queueable class to handle various date ranges that are then sent to a web service. Upon calling the queueable class I am receiving the following error: Callout not allowed from this ...
6
votes
2answers
5k views

Callout Limits for future methods and queueable apex

I'm aware from the docs that "A single Apex transaction can make a maximum of 100 callouts to an HTTP request or an API call." Is anyone aware if that limit is higher in a future methods or ...
3
votes
1answer
196 views

prevent trigger fire from a future method [duplicate]

I would like know if there is any global variable i can use to prevent trigger fire from a future method. Like I can use System.isBatch() to prevent trigger fire from batch classes
0
votes
1answer
436 views

Heap size limit error when making a callout to external endpoint

We are making a callout to external endpoint from Salesforce to get the attachments. when attachment size is more than 6 MB its throwing me Heap size limit error and we are running this callout from ...
1
vote
1answer
118 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
249 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 ...
0
votes
0answers
65 views

Mass Transfer Records: Too many future calls error

My production Org is presenting this error of too many future calls: 51 This error occurs when the user responsible for this task trys to use the Mass Transfer Records option for Accounts. Is there ...
1
vote
2answers
573 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
147 views

Can't Cover @future REST Callout

I have the following trigger and REST-callout class in a source org: trigger SendOpp_Trigger on Opportunity (before insert) { for(Opportunity o : Trigger.new){ SendOpportunity....
0
votes
1answer
332 views

Could anyone help me how to stop recursion of future method by process builder

public class LeadConvertClass { @future(Callout=true) public static void futureCallout(List<String> ledIds){ LeadStatus status= [Select Id, MasterLabel FROM LeadStatus WHERE IsConverted=...
0
votes
1answer
38 views

Testing future methods: data scope

I'm trying to test my @future method, in which I'm performing Custom Object update, but when I'm asserting values, updated object field equals null. Could it be a problem with method scope? I'm adding ...
0
votes
1answer
426 views

How to test partner user community

I have created a user without userrole in my testclass if I run this in my sandbox my testclass gives 100% coverage. When I try to deploy this to production it gives me 0% coverage as I figured out ...
0
votes
1answer
77 views

Test.stopTest() does not run @futureJob called from an enqueuedJob

I have a future job that is called from an enqueued job. The code works fine when I run manual tests; however, when my test class, which looks like the code below doesn't finish the future job: Test....
2
votes
1answer
5k views

Static method cannot be referenced from a non static context in testclass

I am working on a testclass but get the error that my method cant be referenced from a non static context. I have a class where I insert a list of contacts followed by a @future method. I get the ...
0
votes
1answer
654 views

Pass value from one method to another

How do I pass a value from one method to another. I am using a public list with a {get; set;} but this seems not to be working. What I want to achieve is to loop trough the insert from the first ...
0
votes
1answer
373 views

How do I advoid mixed dml operation creating user for community

I am trying to create a list of contacts and add these to the community as users. I keep getting the error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have ...
0
votes
0answers
46 views

used system.enquejob but still facing System.LimitException: Too many future calls: 51 [duplicate]

My trigger trigger triggSendRebateData on RebateData_for_MC__c (before insert,before update) { List<RebateData_for_MC__c> lstRebateData = new List<RebateData_for_MC__c>(); for(...
5
votes
4answers
733 views

Parallel callouts in apex

On some user action, I am calling several different third party services in order to update data in salesforce. As these callouts are time consuming, I would like to execute them in parallel, and when ...
1
vote
0answers
166 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 ...
0
votes
1answer
1k views

Future Method and Static Variables

I have a class that implements Process.Plugin. It calls the invoke method, which calls a future method, which calls a webservice. The returned value from the webservice should be the output parameters....
3
votes
1answer
171 views

Future call from apex:component?

I have 2 Visualforce components inside a main page. Now the issue is that I need to call a @future method from one of them and I think this is not possible. Every time I get an error: System....
2
votes
2answers
946 views

How to get apex job id based on future call

Is it possible to get Apex Job Id in Apex job after executing the future call? Basically I want to get the job Id and its detail information to copy it to another custom object. So after the future ...
9
votes
2answers
829 views

Does queueing a future method count as DML?

We need to implement the following pattern at my org: callout to external data source if that callout takes too long (according to some configurable threshold), log an error (ie do some DML) if that ...
1
vote
0answers
3k views

Future Method cannot be called from batch [duplicate]

I have written a batch class which triggers in after update trigger on the object. This Afterupdate trigger in turn calls the future method. After running the batch class i realise that Salesforce ...
3
votes
1answer
734 views

@InvocableMethod/Process.PluginResult And @Future

Is it possible to set either the @InvocableMethod or Process.Plugin with a @future(callout=true)? My problem (bear with me): I have a trigger that calls a class the class creates an object and ...
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 ...
0
votes
1answer
391 views

How to query more than 50000 records in start method of batch apex?

Problem: I am using SOQL query to retrieve more than 50000 records inside start method and passing those records to query locator. I am getting this error :Too many query rows: 50001 in batch class. ...
5
votes
1answer
611 views

Why do debug logs not always work for a @future method?

I'm working on an Apex class that contains a method annotated with @future. Inside of the method I have a few system.debug statements I'm using to figure out why it's not working. The problem is -- if ...
-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 ...
0
votes
1answer
481 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 ...
0
votes
1answer
230 views

Bulk Future Webservice Calls in Trigger

Is it possible to bulk insert data, that will fire an after trigger, that calls to a web service, and have the web service bulk update each of the records? I know I am running into a number of issues ...
2
votes
1answer
19 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 ...
0
votes
0answers
149 views

Why we can't monitor future jobs in Salesforce

When we run a Future method we can find the Id and jobs in Apex jobs, then why we cont monitor in Salesforce.
0
votes
1answer
83 views

Test Class no getting even 1% coverage

I have the following code I found here: https://developer.salesforce.com/forums/?id=906F000000093JmIAI trigger Lead on Lead (before insert, before update) { if (Trigger.isBefore) { ...
0
votes
2answers
2k views

Assigning and Removing Permission Set via Apex

I'm trying to use apex to assign and remove a permission set in a trigger, but I keep running into issues. Here's my code: public class PermissionSetAssignment_Handler{ @future public static void ...
0
votes
1answer
126 views

managing 'cpu limit exceeded' for slow future jobs

So currently I have a future method that queries all the fields of an object and queries a large chunk of data, then does some nested for loops to map out field usage. The problem is once it is used ...
0
votes
1answer
260 views

Gov Limit - Bulk Update on 500,000 records With @Future

I have two sets of 250k records I need to update in production. I am trying to figure out the best way to attack it. I need to hit a webservice that has a future callout, and then take the data to ...
4
votes
2answers
439 views

Cannot deserialize JSON as abstract type?

While writing a class to help me manage @future jobs for a project, I stumbled onto an error message I can find very little help on. Cannot deserialize JSON as abstract type I used an interface ...
5
votes
1answer
661 views

Session Cache Bug When in @future Context

We built a little framework around managing Session Cache. It wasn't until today we referenced some of the caching methods from a @future method. I understand that in this case it might be better to ...
0
votes
1answer
267 views

How do I make a future call out with data from the response of a future callout

I have a schedulable class that makes a series of callouts to an external email service. I want to take info from the first call out and make another. This code below is part of the SendGridApi Class ...
0
votes
1answer
46 views

How would I go about logging in this scenario?

This is my scenario. I have a trigger on a custom object. The trigger invokes a future method in a class. This future method then does a series of callouts using a helper class to update other custom ...
2
votes
3answers
93 views

Comparing @future vs non-future and beforeUpdate vs afterupdate when using DMLOptions to perform LeadAssignment in an Apex Trigger

When using Apex Database.DMLOptions for invoking standard Lead Assignment Rules, is it sane to use beforeUpdate instead of afterupdate? And is it sane to do this in non-future apex vs (as opposed to) ...
0
votes
2answers
308 views

Running user in future method while running tests

I have a Visualforce page with a custom controller. When clicking one of the buttons, code is being executed and at the end a future method is being called. public static void clickButton() { //...
3
votes
1answer
296 views

Testing future Callouts

I am trying to make a future callout sending email name etc from a trigger when a lead is created which is working. The problem is Testing. I am not sure how to go about making this work. I have been ...
1
vote
2answers
2k views

Delete failed. First exception on row 0 with id xxxxxxxxxx; first error: ENTITY_IS_DELETED, entity is deleted: []

I am trying to Upsert bulk records in Custom object using dataloder. I got error like: FATAL_ERROR|System.DmlException: Delete failed. First exception on row 0 with id xxxxxxxxxx; first error: ...