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
19 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
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
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
3answers
204 views

How to mock System.isFuture()?

I am writing some tests and I have encounter a problem. In my main app I have the following logic: public static void main() { if (System.isFuture()) { System.debug('Is future'); // ...
1
vote
1answer
892 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 ...
-2
votes
1answer
33 views

How to solve read time out error in Apex callout?

Hi all and thanks for reading Got this code: public class SendingZabbixServices{ @future(callout = true) public static void zabbixDoPostFuture(String jsonString, String endpoint){ ...
3
votes
1answer
345 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 ...
1
vote
1answer
29 views

Metadata.Operations.enqueueDeployment Callback not allowing Callouts

I have a scenario where I am saving custom metadata for an external API configuration. I want to deploy all the metadata, then after the deploy job is done, make a callout to the API to verify the ...
1
vote
1answer
29 views

Working with large data volume

I have a design question and I want an expert opinion from the group. Here is the use case: Whenever there is any update on the Booking record (let's say change the status to "Cancelled"), ...
0
votes
1answer
27 views

Time delay @future method - need delay for recurring batch process to complete

I have the following requirement and am looking for advice for the best way to process it. We have multiple orgs linked to each other via S2S, with batch jobs running every 10min to pass updates ...
0
votes
1answer
33 views

Apex Job Execution - Multiple @future Methods in the Same Transaction

Could you please help me with the below queries related to Apex Job Execution: If multiple Async request(future methods) are fired in the same thread, it makes the Async job request status as Queued ...
5
votes
2answers
973 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....
3
votes
1answer
671 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 ...
0
votes
0answers
48 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
1answer
24 views

Using @future in Beforecontexts

Im working with one of our vendors who has a managed package installed in our org. They are currently using an @future method in the before context of a trigger on the Account object. We are ...
0
votes
1answer
26 views

Update Record Field in callout fired from an AfterUpdate Trigger

So I have a Trigger on Account, on the AfterUpdate event (I've also tried on BeforeUpdate), it launches a SOAP Request to a WebService (via a @future method), and this WebService returns a number that ...
0
votes
0answers
35 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 ...
1
vote
1answer
116 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
vote
2answers
41 views

Does Schedulable comes under sync scope or asycn scope?

I have a schedulable class and I am firing 50 future callouts from that. But as per documentation click here,it is mentioned that in synchronous context we can have 50 future callouts and for batch ...
0
votes
0answers
36 views

Writing test class for Messaging.sendEmail()

I am having an issue while writing a test class for a method that sends a report as an attachment in a scheduled email. My method looks like this: @future(callout = true) public static void ...
3
votes
0answers
152 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<...
1
vote
1answer
92 views

Unit testing Schedulable that calls future method

This has been asked here and here, but I'm not satisfied with the answers. Hoping to gain a better understanding of this. In working through the Apex Specialist Superbadge, the callout portion of the ...
1
vote
2answers
162 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 ...
0
votes
1answer
286 views

Future Callouts and Queueable from a Trigger

I am pretty new to salesforce development. I am trying to make a Callout to the third party API whenever a Account record is created in Salesforce. I tried to make the future callout and didnt realize ...
0
votes
1answer
87 views

Bulkify trigger to future Callouts

I asked another question on the future callouts which was throwing the SystemLimitException, the recommendation was to use the Queable or making the future Callouts bulkified from the trigger. I tried ...
1
vote
1answer
24 views

Using Scheduled Callout response to trigger another callout

I'm having trouble with my current callout/trigger setup. My current architecture is like this: Scheduled job - runs every 5 minutes: global class Scheduled implements Schedulable { global void ...
0
votes
1answer
78 views

Future Callout Throws: System.LimitException: Too many future calls: 51 [duplicate]

I am trying to call the external API endpoint from Salesforce when an account is created. I created a trigger on the Account which looks like below trigger createSegSubSegmentD on Account (after ...
0
votes
1answer
37 views

Trigger Future Callout

I am updating a field on an object from calling future handler in before update trigger, but field value is not get updated on UI. I have to refresh my detail page to see the updated changes. Can I ...
0
votes
1answer
32 views

Assert for Test Class for Future methods without any DML operations

I am trying to write a test class for a @future method which makes a REST callout whose response is just 200 {"status" : "ok"}. It does not make any updates to records. I am finding it difficult to ...
0
votes
1answer
2k 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....
0
votes
0answers
45 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 ...
2
votes
1answer
49 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 ...
3
votes
2answers
699 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
49 views

Issue with using a Class inside a Trigger: “Method does not exist or incorrect signature”

I am currently trying to get this trigger to work: trigger ContactRelatedOpportunities on Opportunity (after insert, after update) { List<Opportunity> Opps = [SELECT Id FROM Opportunity ...
1
vote
1answer
171 views

Trigger firing in @future needs to do callout

We are co-developing some code with a external vendor. We wrote some custom code that when certain field on the contact are updated, it creates a record in a sync object(SyncLog). Then there is a ...
25
votes
5answers
29k views

Calling future method from Batch

I have a requirement where a future method need to be called from batch apex ,I came across various articles stating that a future method could not be called from the batch. Is there any alternate ...
1
vote
1answer
110 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 ...
0
votes
2answers
210 views

How to refactor Synchronous code with future method

I have a future method that is called in trigger to create some records, and after that i use the records created in the future method to associate them with other entity. Since future methods are ...
0
votes
1answer
148 views

You have uncommitted work pending. Please commit or rollback before calling out even if we put DML in future method

I know as per documentation, we cannot perform DML and then callouts from apex class. In my scenario, I have a callout then I am performing a DML which is placed inside a future method and again ...
0
votes
0answers
43 views

how to handle platform events from flow when received as a batch at once

I am creating a flow that uses an Apex action that calls multiple future methods in quick succession and publishes platform events for each of them when they are done. There is also another flow with ...
0
votes
1answer
348 views

can i use multiple annotations in one apex class

can i use multiple annotations in single apex class; like i have the scenario of calling apex class from process builder which is having future method,suppose i am using setup objects and non-setup ...
0
votes
0answers
146 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
2answers
150 views

Database.rollback() Method Not Working In Different Transaction?

I have created a very simple scenario where I'm creating a savepoint and trying to rolling back in future method. The behaviour is little confusing - I tried searching it over the net but I didn't ...
1
vote
1answer
303 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,...
0
votes
2answers
229 views

Serialize and deserialize a list of Sobject for Future method

I am trying to pass a list Account records to a future method. Since future can only take primitives, I am planning to serialize and deserialize the Sobject. I tried below: List<Account> acList;...
2
votes
0answers
32 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 ...
0
votes
1answer
44 views

DML in @Future called from Trigger in Batch

I have a after insert trigger on an object that calls a @future method to do a callout to an external system. If the callout fails I want it to update the original object. I am batching up 100 at a ...
0
votes
1answer
73 views

How to make two callouts in sync?

From Trigger on inserting I am making a callout (from method1 of class A) i.e by using @future annotation and updating the field of the same object on which the trigger called, with the values ...
1
vote
1answer
350 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 ...
0
votes
0answers
28 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 ...

1
2 3 4 5
8