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

User Friendly Handling of Exceptions in Future Methods

Background Salesforce is integrated with an external system, like Xero Accounting. When the User updates an invoice status 'Sent' Salesforce creates it in Xero. Process Builder calls an @...
3
votes
1answer
2k views

Batch, future and MIXED_DML_OPERATION

One of the requirements for out project is to do some complex logic on both setup and non-setup objects. In short, whenever a field on Account is edited, we should recalculate our custom sharing for ...
3
votes
1answer
2k views

@future method vs Async callout

Some days ago I imported a WSDL into Salesforce and (different of some years ago) it created an Async class (and of course the sync class). So I decided to search on Google how to use this Async class....
3
votes
2answers
1k views

UserInsertUpdate: System.LimitException: Too many future calls: 51

I have a trigger on User that after it's inserted or updated, I want a contact for that user to be created. For example, if a new user Fred is created, I also want a contact created with Fred's ...
3
votes
2answers
1k 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 ...
3
votes
1answer
2k 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 ...
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/...
3
votes
1answer
1k views

How can I create over 10,000 records with information from Visualforce?

I have an inventory input page that I am working on and I am running into an issue where I need to create more than 10k records. The problem here is that all the information needed is not stored in an ...
3
votes
1answer
2k views

Call @future from @RemoteAction?

Can you call a @future method from a @RemoteAction method? I've got an installed package that runs a VFRemoting and they allow me to write a plugin for part of the process. The issue is, I'd like to ...
3
votes
1answer
329 views

Null Pointer on system.debug in @future method

Can someone explain the error? I have a trigger that passes a set of Event IDs to an @future clas. Below is the class: public class eventChatterFuture{ @future public static void ...
3
votes
1answer
255 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....
3
votes
1answer
438 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 ...
3
votes
1answer
956 views

Can flow commit changes prior to invoking a method?

I'm trying to get some advanced architecture setup for my company, but I'm running into an issue with my design; looking for help. I'm attempting to execute an API call from Flow, but I'm getting the ...
3
votes
1answer
137 views

Create a Class that I can access from my trigger to login as another user

I need to be able to impersonate another user from my Trigger, and thinking that I could create a class that logins as another user using the REST API and then post messages from that class. How ...
3
votes
1answer
631 views

Sending HTTP callout after a Lead record is updated

I have a requirement where I have to send Lead data from Salesforce to TIBCO server once Send_to_CRM__c check box goes from false to true on Lead update. Once updated 2 web-services are suppose to go ...
3
votes
1answer
706 views

How to prevent inconsistent data when using @future methods in triggers?

Due to certain governor limits in my trigger I refactored it to work asynchronously with @future: public with sharing class CustomObject_TriggerHandler { public static void afterInsert(Map<Id, ...
3
votes
1answer
318 views

NULL POINT Exception

I am getting NULL POINT Exception error when running my unit tests and can't seem to figure out how to go about this one. This is the error Message; |FATAL_ERROR|System.DmlException: Insert failed....
3
votes
1answer
460 views

Does a VisualForce page embedded in a page layout have to finish executing before the page will load?

Thanks for reading my question. I am looking to create a trigger on the OpportunityContactRole which is unfortunately not supported (I'm curious as to why, if anybody has insight on that, but that is ...
3
votes
1answer
617 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
1k 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
2answers
404 views

@future callout + button + multiple clicks = multiple callouts instead of one

I have a button(with Javascript for call apex class) in Opportunity object. I have Apex Class with @future Callout for sending information about Opportunity to Jira. And it's work fine, except one ...
3
votes
2answers
1k views

Getting @future method complete before startTest()

Is there a way to wait for all @future method completes before starting the test? I think Test.startTest() does not wait for future methods. I need the future method to be done in order to setup data ...
3
votes
1answer
101 views

Passing Paramaters from a future class to another class

I am trying to pass some parameters from a future class to the constructor of another class and it is passing nulls values. What is the reason for it? (FYI-The @future class is called from a scheduler ...
3
votes
0answers
642 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
143 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
1answer
243 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....
3
votes
0answers
108 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
1answer
6k views

How to execute and run a Trigger as a System Administrator

To start, I know that you can only use System.RunAs with test methods. Now that we got that out of the way, I have a trigger that is executing an operation that the current user can't do with their ...
3
votes
0answers
760 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
750 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
2answers
1k views

Future Method Static

I am new to Salesforce and hence a lot of silly questions. What is the rational behind defining future methods as Static? I mean has these methods been not static what harm would have they caused?
2
votes
2answers
8k views

Help with calling future method from trigger

I installed Payment360 and I am trying to capture a transaction from a trigger. Payment360 offers the following documentation: payment360 documentation Through trial and error I see that i need my ...
2
votes
1answer
3k views

Processing callouts from Batch

I have a tough scenario where a future method should be called from a batch.I came across various articles stating that it is not possible. My scenario is i need to send emails for contacts of account ...
2
votes
1answer
426 views

The future of Async Apex - everything Queueable?

I know that this is a somewhat opinion based question but there is definitely interest in the community in where the Roadmap goes. Do I get the blogs and communities and blogs right that we are ...
2
votes
1answer
758 views

Http callout test class "uncommitted work pending" error with no clear cause

We have method EnrollmentUtil.createNewEnrollment which contains a http callout on create of custom object Enrolment__c, and a test class to test this method. I'm trying to figure out how this class ...
2
votes
2answers
2k views

Notify users of errors that occur in a future method

How can I notify users of errors that are encountered within a future method? Outside of a future method I'd usually resort to ApexPages.addMessage(), but this isn't possible without the browser ...
2
votes
2answers
832 views

Why am I not able to get full 60 second CPU time in @future method with getContentAsPDF()

I'm trying to generate a PDF, and in normal Apex execution the function is haulted due to CPU timeout (exceeding 10 second execution time). So I tried using @future annotation to use Asynchronous ...
2
votes
2answers
1k views

System.CalloutException: You have uncommitted work pending during Test for callout in @future method

SOLUTION An object has workflow rule that sends an email and it was not mocked EDIT I am simply trying to test future method that invokes SOAP service, but I get an exception. EDIT 2 I have @...
2
votes
1answer
510 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 ...
2
votes
2answers
527 views

method @future two transactions

In an @future method can I persist a data at the beginning of the execution and the others at the end? Pratically, can i open and close two different transactions in the same @future method?
2
votes
2answers
921 views

future method concurrency

I have a button that calls a very complex feature that caused salesforce limits to be reached. I modified the method in asynchronous (@future) and added two states: "waiting" and "not processed". ...
2
votes
2answers
2k 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 ...
2
votes
3answers
161 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) ...
2
votes
1answer
4k views

Too many queueable jobs added to the queue: 2

I am trying to update user records using batch and I am getting this error Too many queueable jobs added to the queue: 2 I found out that the batch update is triggering triggers on the user and ...
2
votes
1answer
10k views

Is it possible to call Batch from a future call?

I was wondering if it is possible to call a batch from a @future method? The reason I am asking as you may have guessed is because I am trying to call batches from a trigger. Eg: Leads are inserted ...
2
votes
1answer
164 views

Heuristics to decide if to run an operation sychronous or asynchronous

Im our app we recently had to switch many operations from short running synchronous calls to asychronous Batch or future calls. It helps us overcome the many limits but also introduces many other ...
2
votes
3answers
2k views

Options for callouts from triggers

I need to make some callouts from code that initiates from a trigger. I realize that you can't do a callout directly from a trigger. Currently what I do is make a future call to code that then ...
2
votes
3answers
425 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 --&...
2
votes
1answer
33 views

Performing mass data evaluation using @future

I have a use case of creating/updating the records for a custom object based on a specific Account's record type. Its on the click of a custom button placed over detail page, its working fine for a ...
2
votes
1answer
794 views

DML operation Delete not allowed

I am receiving the following errors: DML operation Delete not allowed on List<AccountHistory> DML operation Delete not allowed on List<ContactHistory> List<ContactHistory> conHis = [...

1 2
3
4 5
9