Skip to main content

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.

Filter by
Sorted by
Tagged with
4 votes
2 answers
2k 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 ...
Robert Sösemann's user avatar
4 votes
2 answers
2k views

How to avoid running a batchable when an instance is already running?

We have several batchables that if run in parallel trample over each other's results. So I want to block a second invocation if there is already one running and just tell the user to wait. My first ...
Keith C's user avatar
  • 136k
4 votes
3 answers
2k 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 ...
Robert Sösemann's user avatar
4 votes
2 answers
5k 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 ...
user823447's user avatar
4 votes
1 answer
297 views

Using @future tag on Apex Webservice but code not executing asynchronously

With the winter '15 release over the weekend some mission critical code for us is now getting the infamous "Apex CPU time limit exceeded". It worked fine for the past 8 months until this release. (as ...
StartingAgain's user avatar
4 votes
1 answer
3k views

System.AsyncException: No enclosing class for method: methodName

I have this error that says "System.AsyncException: No enclosing class for method: methodName". The code structure : trigger trgSendRecords on DataSetup__c (after insert) { /* SOME BUSINESS ...
Mohd Nadeem Shaikh's user avatar
4 votes
1 answer
7k views

Can Database.executeBatch be called from a Queueable started by System.enqueueJob?

I'm aware that you can't call Database.executeBatch from the execute method of an already running Batchable. But can Database.executeBatch be called from a Queueable running via System.enqueueJob? I'm ...
Keith C's user avatar
  • 136k
4 votes
1 answer
672 views

Change Data Capture vs Queueable Apex

With the introduction of Change Data Capture, now there is one more way to execute Asynchronous Apex. What are the advantages of Change Data Capture over Queueable Apex? How Salesforce will enqueue ...
Devendra's user avatar
  • 5,075
4 votes
1 answer
888 views

Keep track of chained Queueable

I'd like to insert a lot of records. Chaining Queueable classes seems to be the way to go in my scenario, I am just wondering if the following is feasible: keep track of chained jobs - when first job ...
Bart Juriewicz's user avatar
4 votes
1 answer
2k views

Testing the ACTUAL batchable context in Database.Batchable methods?

I'm trying to mock Database.BatchableContext to make my unit tests more robust and to eliminate excess usage of Test.isRunningTest() running in production code. Few hacks are available like Json....
Matt and Neil's user avatar
4 votes
1 answer
3k views

Does Test.stopTest() cause ALL waiting asynchronous functions to fire?

For practice, I'm composing on a unit test for a Schedulable class: /** * Example of scheduling Apex Batch Processing * @see Apex Workbook, page 68 **/ global class WARE_CleanMerchandiseScheduler ...
Brian Kessler's user avatar
4 votes
1 answer
371 views

Are start() methods of batches guaranteed to run sequentially?

The question is very similiar to this one: Are batch jobs guaranteed to run sequentially? I basically want to ask the same thing, except this time for start() method. Do start() methods of ...
Kamil Pilarski's user avatar
4 votes
1 answer
1k views

Batch execute is slow because of huge unused gaps in DevConsole timeline

I have a long running batch that is taking days to execute and creates millions of records. To speed it up I used the profiling tools of the Developer Console. Per batch execute() I see this timeline ...
Robert Sösemann's user avatar
4 votes
1 answer
300 views

Is there any way to unit-test that a function will run into a LimitException?

I need to write a test that verify that a function call is run synchronously. As I have found no elegant way to find that out I now let my function run into a Limit which is an indirect proof that ...
Robert Sösemann's user avatar
4 votes
1 answer
358 views

How bad an idea is it to make a server side "save" call in disconnectedCallback?

This LWC lifecycle method is documented as: Use disconnectedCallback() to clean up work done in the connectedCallback(), like purging caches or removing event listeners. Not that the set of ...
Keith C's user avatar
  • 136k
4 votes
1 answer
316 views

Does Apex Engine maintains old version of apex code for Async Apex?

Suppose I have a batch running that is processing millions of records(that would take hours), then I deploy a code during execution that changes the batch logic, will remaining record get processed ...
Pranay Jaiswal's user avatar
4 votes
1 answer
293 views

CDC processes all 9999 requests at once. Is this by design or a bug?

In salesforce documentation batch size of platform event is mentioned as 2000 maximum (documentation). Which it definitely follows (tested). But for CDC its not mentioned. I also tried this in my dev ...
Nagendra Singh's user avatar
4 votes
1 answer
1k views

Avoid new record race conditions with FOR UPDATE [closed]

Under simple circumstances FOR UPDATE does only respect records that existed when the query was executed. But I need all available records matching my query when the transaction proceeds. Let me ...
itsmebasti's user avatar
  • 6,477
4 votes
0 answers
272 views

Can a Change Event Trigger include the same record multiple times?

I'm starting to play with Change Event Triggers, building a handler framework and I'm not sure if I need to handle a scenario where the same record would be included in the same Change Event trigger ...
Mike's user avatar
  • 1,199
3 votes
3 answers
3k views

JavaScript Remoting on Standard Page Layout

I have a couple of JavaScript remoting functions used to count records and to display that count to the end user. The JavaScript remoting functions are on a Visualforce page, and the Visualforce page ...
Tony H.'s user avatar
  • 206
3 votes
1 answer
2k views

Testing multiple asynchronous processes

I have a test that for it's data setup I need to fire multiple asynchronous processes. I have a suspicion, that they do not finish sequentially one after another. I think Test.startTest()/Test....
dzh's user avatar
  • 4,165
3 votes
2 answers
2k views

Why would a future method not show up in debug logs?

What are some possible reasons a future method wouldn't show up in the debug logs? @Future(Callout=true) global static void myFutureCallout(Id testId){...
Olivia's user avatar
  • 3,471
3 votes
2 answers
3k 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. ...
PartOfTheOhana's user avatar
3 votes
1 answer
7k views

How to check if future method has executed

in my apex code I need to do some calculation only when future method has executed I tried below code to check if future method has executed: public static void anotherMethod() { while('Completed' != ...
gs650x's user avatar
  • 2,680
3 votes
2 answers
325 views

Imperative Call Using Await In LWC

Is it possible to imperatively call a function from a wired function using async/await? And yes, I've seen similar questions - but they kinda miss the point I'm trying to make. Consider this simple ...
Semmel's user avatar
  • 2,507
3 votes
3 answers
2k views

Promises in Apex?

We have a very complex scenario where we have multiple external systems that we interact with and we need to make sure the data is valid across multiple external systems before it gets processed ...
jojopogi's user avatar
  • 512
3 votes
2 answers
2k 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 ...
Brian Kessler's user avatar
3 votes
2 answers
1k 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 ...
VarunC's user avatar
  • 6,000
3 votes
1 answer
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....
Átila Castro Alves's user avatar
3 votes
1 answer
61 views

Is Lead.Name 100% predictable?

We have an integration with a third party site which requires an exact match for the Lead Name. When we have a new lead, we need to make a call out to this website. In Trigger.new, Lead.Name is always ...
Brian Kessler's user avatar
3 votes
1 answer
913 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, ...
Olivia's user avatar
  • 3,471
3 votes
1 answer
332 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 ...
Bartosz Beli PL's user avatar
3 votes
1 answer
428 views

How to monitor not yet started jobs of a Queuable chain

I am wrapping my head around how to use Apex Queuable as a queue and not as a chain. As I understand all the code samples out there, the next job is enqueued after the work of the previous one is done....
Robert Sösemann's user avatar
3 votes
1 answer
102 views

Does the FOR UPDATE field apply to reference fields?

If do a query like [SELECT Opportunity.Name, Product2.Name FROM OpportunityLineItem FOR UPDATE], is the Opportunity and Product2 locked, or just the OpportunityLineItem? I'm trying to set a field on ...
just_chilling's user avatar
3 votes
1 answer
358 views

When and why do I need to perform an .isValid() check?

This document - Modifying Components Outside the Framework Lifecycle - says the following: You don't need a cmp.isValid() check within this setTimeout() call as the cmp.set() call doesn't do ...
Eduard's user avatar
  • 5,181
3 votes
2 answers
5k 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 ...
Cissou's user avatar
  • 83
3 votes
2 answers
968 views

Performing on-demand record updates in real-time, asynchronously

I am trying to understand how the real-time mode of the Rollup Helper app works behind the scenes. I am looking for ways this can be achieved with, not necessarily how the developers built this ...
Mossi's user avatar
  • 3,986
3 votes
1 answer
1k views

Why does my ActionPoller wait for my batch process to be done before it polls?

I have a CommandButton that calls a method in the controller that starts an Apex batch processes. I have an ActionPoller that is supposed to get the current progress of the batch process and update ...
Neo's user avatar
  • 775
3 votes
4 answers
5k views

Asynchronous Callout from an Imported WSDL

I developed VisualForce page with asynchronous callouts to web service according to link. It is working fine, my page is showing results after callback is returned. I really like pattern with ...
mischczu's user avatar
  • 329
3 votes
1 answer
171 views

Invocation of scheduled class : starts - schedules - completes without a trace. No debug log

I've got an Apex Class that implements System.Schedulable which I'm trying to run: public class Broker { //... public class Worker implements System.Schedulable { public void ...
Matt and Neil's user avatar
3 votes
1 answer
327 views

How can I decompose a Lightning Component Helper to escape deep nesting hell?

I'm trying to figure out more maintainable ways of composing Lightning components. I'm currently looking at the helper on Display Weather Alerts in Lightning Experience, trying to break it down into ...
Brian Kessler's user avatar
3 votes
1 answer
2k views

Making an Asynchronous Callout from another class

I have a question regarding Making an Asynchronous Callout from an adapter class that I made in apex. Description: So i followed the Making an Asynchronous Callouts from imported WSDL guide from ...
zeev1079's user avatar
3 votes
1 answer
382 views

Best architecture solution for Mixed DML Exceptions inside a Batch

I am writing an apex Batch First I am updating a few EmailTemapltes and then I need to write to a custom object. public void execute(Database.BatchableContext context, List<EmailTemplate> scope) ...
Marko's user avatar
  • 31
3 votes
1 answer
1k views

LWC: Second async child function call fails

I would like to call an async function on a child component from its parent. This works the first time I call the function, but the second time, I get a "Sorry to interrupt" error with this:...
Matthew Souther's user avatar
3 votes
2 answers
1k 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 ...
Hemant Keni's user avatar
3 votes
1 answer
2k 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 ...
torpy's user avatar
  • 355
3 votes
0 answers
2k views

How to Target Element In Modal After Opening Modal

I have a custom modal component (with slots) that can be opened and closed. In a parent component I'm using this modal component and inside the body slot of the modal I have a <lightning-input> -...
jbyrd's user avatar
  • 661
3 votes
1 answer
2k views

Concurrent Request Limit Exceeded - Possible Solutions

In the recent past we've replaced two very old s-control type and html mashups with visual force pages and web services. This changes along with a few other visual force pages built into our standard ...
KcBrewRon's user avatar
3 votes
1 answer
339 views

Continuations (Async Web Services) in Spring 15 Sandbox [closed]

According to Spring 15 release notes, Continuations class should be available in Spring 15. I have a preview Sandbox (on CS21) but this feature does not appear to be enabled as the Apex does not ...
John Davies's user avatar
3 votes
0 answers
360 views

Why does this Batch always and only abort in Production?

I have a long running asynchronous process that process millons of records in a CustomObject__c. To prevent other limits we have split this into 2 Batch classes that work on this table in parallel. So ...
Robert Sösemann's user avatar

1
2
3 4 5
7