Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [asynchronous]

An asynchronous process is a process or function that executes a task "in the background" without the user having to wait for the task to finish. Typically, you will use Asynchronous programming for callouts to external systems, operations that require higher limits, and code that needs to run at a certain time.

4
votes
2answers
50 views

Spin locks with variable time retry backoffs

Use Case After insert triggers start Queueable Queueable execute() contends for same resource, uses spin lock to wait for resource availability. Many queueables could be running at same time. ...
2
votes
1answer
38 views

Get the actual Previous Fire Time of a CronTrigger / Scheduled Apex

I am exeuting Scheduled Apex that should do processing based on the last execution time of the particular code. I query some records for processing and I only want to query those records, that have ...
-2
votes
1answer
38 views

System.AsyncException in trigger

Trigger Snippets: if (JIRA.currentUserIsNotJiraAgent()) { if(System.isFuture() == false || System.isBatch() == false || System.isScheduled() == false) { //Check, If Not in any Async Apex ...
5
votes
2answers
65 views

How to disable asynchronous jobs so that they cannot update data

There will be a data export happening from our org for large number of objects and records using a cloud based ETL tool. We have a business scenario where we need to make sure that there is no data ...
1
vote
1answer
29 views

Uncommited work exception in Queuable with Callback and Rollback

Is there a way to do all that Do Callout in Queueable Do Dml based on the Callout result Catch errors in 1 and 2. Rollback 1, 2 on error Report error via email and log in Custom object without ...
4
votes
2answers
188 views

Send out email when Apex Queueable fails and test it

This question definitely is a duplicate of many questions here, but after reading most of them I am still somewhat clueless. Question 1: why I can't just catch exceptions in the execute and send an ...
2
votes
1answer
100 views

Waiting for results from APEX call in a for loop

I need to load a number of records more than the 2000 default limit for an SOQL query, but I need to wait until all of them are loaded before moving on. To do this, I make a request to get the total ...
0
votes
1answer
22 views

async internal calls from visualforce, any quick examples?

often async calls are used to callout, but what do async calls look like when an org asynchronously queuries itself, so what do “internal async calls” look like in general, and when done from ...
2
votes
3answers
112 views

Overcome Queueable maximum depth limit in dev orgs

To migrate "trees of related data" from an external system to Salesforce I am using dynamic chains of Apex Queueables. Imagine I am "synchronizing" Accounts, Opportunities and Contacts from an ...
-3
votes
2answers
18 views

While trying to run ScheduleApex it give error

//This is code global class Schedule1 Implements Schedulable{ global void execute(SchedulableContext sc){ List<Account> accounts=[SELECT ID,NAME,INDUSTRY FROM ACCOUNT WHERE NAME='...
0
votes
0answers
48 views

Using promises with aura component callbacks

I noticed there a number of questions listed regarding this topic but I don't have the time to parse through all of them and look for the relevant information. I was hoping someone could quickly ...
0
votes
1answer
71 views

What is the life-cycle of static properties in Apex classes?

Sometimes when developing Apex, I've populated some static property. But then later -- most often in an Async or Test context -- I go to access it again and discover SFDC is behaving like it is ...
0
votes
0answers
34 views

Calling Salesforce Rest Webservice url from vf controller

Hi I am trying to make a rest callout from controller and I am not been able to get response . I am using apex continution callout pattern for this to make call async. This is controller class ...
1
vote
1answer
29 views

Command pattern with batch finish method

To chain a execution of a batchable object, I pass the batchable contructor a ICommand. public interface ICommand { void Execute(); } When testing this approach I create a test ICommand which ...
2
votes
2answers
82 views

Unable to do callout from PostInstall Script

As per the Salesforce documentation, Post-Install script can perform callouts using an async operation only. https://help.salesforce.com/articleView?id=apex_post_install_script.htm&type=5 So, I ...
2
votes
2answers
168 views

How do static and member variables behave in a. stateful batch classes?

Suppose I have a batch job and I want to maintain state (i.e. want to keep a log of the record ids that I've processed, or keep a running total, or something). When would I use class variables vs. ...
0
votes
0answers
41 views

Getting status null in apex continution callouts

I am getting this response for all urls System.HttpResponse[Status=null, StatusCode=200] in my continution object Here's my code public with sharing class ContinuationController { // Unique ...
1
vote
0answers
19 views

Custom component taking long time to load

I'm having a record page with an heavy custom components. By heavy I means like 20 seconds of loading time. I'm trying to find a way to load it asyncronously without blocking the UI of the User. ...
5
votes
1answer
322 views

How do I test asynchronous Apex?

This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through ...
0
votes
1answer
148 views

Exception in @Future Method - System.QueryException: Record Currently Unavailable

I am facing error in one of future method (calling from trigger handler). This error occurs when integration event submit these record in bulk but when i am doing this from UI i do not get this error. ...
5
votes
2answers
190 views

Enforce Batches (whole run, not single jobs) to wait for each other

A few situations in my app trigger a Clean up batch to run. It will process many records. In some situations multiple of such Cleanup batches will be triggered by independent user operations. If the ...
-1
votes
2answers
141 views

Design Patterns for Asynchronous Apex

Background After listening to Dan Appleman's talk: Dreamforce 13: Design Patterns for Asynchronous Apex I went to look at the code: Sample Code: Design Patterns for Asynchronous Apex ...
2
votes
1answer
193 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
1answer
438 views

Custom Logging and Future Methods

I have been reading up on the custom logging, DML, and exceptions but haven't seen anything that talks about @Future methods and exceptions. I have two scenarios: A Button is clicked on a Lead, ...
1
vote
1answer
53 views

Initialize jQuery plugins with ui:outputRichText in Lightning component

I have a Lightning component that displays record's content as rich text. The content contains HTML code and I need to make it work with jQuery on click handler and some plugins. The content comes ...
0
votes
3answers
201 views

Is asynchronous apex either rolled back or not executed if the original transactions fails?

I would like to confirm the behaviour of asynchronous apex when an error occurs on its original/parent transaction. Imagine we have a synchronous apex transaction (Transaction1-Apex) that launches a ...
1
vote
2answers
124 views

Can Salesforce Platform Events be Relied on as an Async Solution?

Recently I was working on a project where, in order to deal with recursion and governor limits, the previous developer decided to send Platform Events, with the expectation that the very same ...
0
votes
1answer
81 views

Issues in Scheduled Apex

Error:First error: Delete failed. First exception on row 0 with id a2A0R000003T2DMUA0; first error: ENTITY_IS_DELETED, entity is deleted: [] Note: Above error occurs to me as a concurrency Issue. ...
0
votes
1answer
51 views

What async notification options are available in OOB LEX UI?

I have created a trigger that validates user input against a web service after insert/update. Originally, I wanted to show a validation error on the data entry screen, but this is not possible due to @...
2
votes
2answers
134 views

Queueable Apex consideratoins

This is more of a theoretical question and probably goes more to design and I hope I can do this justice. I have successfully coded in apex multiple triggers which make callouts using the @future (...
1
vote
1answer
73 views

Execute Javascript on VFP from Controller Query Results [closed]

I have a Visualforce Page with inputs, these input values are passed to a controller, query results are returned, and results are displayed in a datatable on the same VFP with inputs. If the list I ...
-1
votes
2answers
54 views

Calling one asynchronous apex from another [closed]

Can anyone provide me when we can call an asynchronous apex from another specially between when they are not of same type like schedulable from future or batch from schedulable,etc
0
votes
0answers
33 views

CloseTab Callback Function not Executing

Callback function is not executing in console tab method closeTab, but the id provided to the method IS closing. Why? function callback (result) { console.log('in callback'); }...
1
vote
1answer
108 views

Synchronizing force:recordData and external JavaScript library on loading

I've got situation in lightning component where on init there should be used data from two sources: record loaded via force:recordData data from this record parsed with use of external JS library ...
0
votes
1answer
28 views

External Application receiving multiple Success Pings

For the SFDC Integration I send out a call to an external application and receive a Success status in my debug log(I am logged in as myself). External application says they are getting multiple pings ...
0
votes
1answer
75 views

What is the execution context for an asynchronous method?

Is it always system context, or it depends on where the method is called?
2
votes
2answers
1k views

What's the difference between AsyncApexJob and CronTrigger?

Roughly I know that when I schedule a Schedulable, I'm creating both a CronTrigger and an AsyncApexJob, but I'm confused as to how the two objects relate to each other and what the significance of ...
1
vote
0answers
316 views

Apex Continuation - Response Method

I am using Apex Continuation to make a callout from a VF page, but the response method is not being executed and, as a result, no response is displayed on the page. Can anyone please see why this is ...
1
vote
1answer
383 views

Best way to add a progress bar to indicate loading?

I've got a complex process that takes about thirty seconds to execute, depending on how many records are in the org. I can estimate the completion percentage by iterating a count variable in my for ...
1
vote
1answer
142 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 ...
2
votes
2answers
199 views

Asynchronous Apex-->Future Method challenge

I am doing the challenge for 'Asynchronous Apex-->Future Method' module and have written following apex classes: public class AccountProcessor { @future public static void countContacts (List&...
-2
votes
1answer
78 views

Help in writing Asynchronous Batch Apex to avoid governor limit of 150 records

I have a function that has the DML operation inside the for loop due to which I am running into governor limit exception of 150 records. I read about batch apex on Salesforce discussion about not sure ...
10
votes
2answers
278 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 ...
5
votes
2answers
4k 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 ...
0
votes
1answer
66 views

Cache value not being saved in Org from Async call

I have a batch call that calls a queuaeble that calls a future call which utilizes a visualforce page 'getContentAsPdf' function. Also in this queuable call I set a custom class value to a local ...
-1
votes
2answers
96 views

SOQL Query on PricebookEntry returning no rows

I'm trying to create a queueable apex class which will update the unit prices of all Products (on all Pricebooks) based on newly updated exchange rates. I'm able to successfully query on ...
0
votes
3answers
286 views

Getting the job id of a chained job from the id of the parent job

I have a Queueable job that will initiate a Batch job. I have a transaction that enqueues the Queueable job and returns the id of the Queueable job. However, I need to be able to get the id of the ...
1
vote
1answer
377 views

How is calculated “24-hour period” for the limitation of Asynchronous Apex Executions

I have a question regarding Execution Governors and Limits for daily maximum number of asynchronous Apex method executions. In the Salesforce documantation it is written, that the maximum number of ...
0
votes
1answer
22 views

Pitfalls or risks in having a scheduled job run every 1 minute

I've got a requirement to know which Contacts are associated to Open Opportunities, and it needs to be known very quickly upon OpportunityContactRole creation. As we all know, OpportunityContactRole ...
2
votes
1answer
62 views

Short delayed (asynch) related record updates

I feel like there should be a straightforward answer here, but I'm coming up short... Trigger event: Account lookup field on Lead(s)/Contact(s) are updated OR a particular Account field is updated ...