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
0
votes
0answers
18 views

Why is SerialBatchApexRangeChunkHandler more than the number of batches?

I am working on batch apex and I have just tried writing a simple code for learning purpose. In the start method I am querying the records limiting them to 7, and I am running the batch job from the ...
0
votes
2answers
54 views

How to use Promises / synchronize two asynchronous methods in Lightning Web Component(LWC)?

In LWC JS, I am making an external API call-out and an Apex method and accumulating the results. How to synchronizes the process? Example: renderedCallback(){ let a,b; getApiResult().then(...
2
votes
1answer
93 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' != ...
1
vote
0answers
18 views

Report Rest API (asynchronous run and excel export)

I'm trying to use Report Rest API to filter and export some of my reports. My first approach with synchronous report runs works pretty well, but I bumped into 500 batches' run per hour limitation. I ...
9
votes
4answers
92 views

Run more than one async jobs from Future/Quable context

We have created a process which must work asynchronously (limits and architecture reasons) and it was working fine. Some time later we have started to work with BigObject. And as long as writing to ...
2
votes
1answer
30 views

Need advise on callouts and inserting/updating new records from external system

We have an external application where few records gets updated or created on daily basis. We already implemented inbound calls to salesforce but it is scheduled for once a month. We need to schedule a ...
1
vote
1answer
17 views

how quable solves the problem of having soobjcets in future mthods?

As per my knowledge both future and quable are async methods ,we don't know when they run,that's y we cant pass sobjects as parametrs in fuute methods(i read in future trailhead) because objects state ...
-1
votes
1answer
30 views

Continuous integration using REST api in vf page

I have been asked a question in continuous integration. First let me give some background. In continuous integration api call we can call 3 webservice urls at a time and process response in another ...
1
vote
1answer
41 views

Queueable call not executing in case of partial success using Database.update

I have written logic that enqueues queueable class from trigger of one object. This works perfectly when I update records and all records gets updated successfully,but in case of partial success I can ...
-1
votes
1answer
46 views

Future method use response to make update on Opportunity object

I have a future method where I make an external REST api call which gets kicked off in an after update trigger on the Opportunity object. When the results come back, I deserialize the JSON and then ...
1
vote
1answer
47 views

RequestAnimationFrame in LWC

I'm implementing a pretty straight-forward animation in LWC (Lightning Web Components). My normal approach to doing animations within JS is to use requestAnimationFrame, but the linter rules in LWC ...
0
votes
3answers
44 views

Can Queueable run in parallel with calling transaction?

SimpleQueueable.cls: public with sharing class SimpleQueueable implements System.Queueable{ public void execute(System.QueueableContext ctxt){ //query the record inserted in calling ...
0
votes
0answers
44 views

Salesforce Synchronous and Asynchronous Web Service Callouts

Just trying to clarify some confusion. From my understanding, we can use Salesforce to make Web Service Callouts in an Asynchronous manner in 3 different ways; using @Future, Outbound Messages and ...
0
votes
0answers
52 views

Finding out when lightning-record-form has finished rendering?

I have a LWC which displays the Compact Layout as a popup in a graph using lightning-record-form. The LWC holds a <slot> in which the popup-lwc has the record for like so. <template> &...
3
votes
1answer
49 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 ...
4
votes
1answer
126 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 ...
0
votes
2answers
38 views

Get ApexJobId from Future method

Is it possible to get the ApexJobId within the Future method apex code (or from the method its invoked from)? Use case - Our application is invoking multiple same future calls from within one apex ...
1
vote
1answer
25 views

How come Queuable apex accepts sobjects where as future methods doesn't? [duplicate]

As we know we cant pass sobjects to @future method due stale of data during the processing time,where as not same in case of Queable apex.How exactly its working by using Sobjects here?
2
votes
1answer
145 views

How to tell my lightning web component the data has been loaded through a mix of imperative and @wire operations

TL;DR whats the best way to tell a page that the underlying data has loaded through a mix of imperative calls and wire calls, preferably without chaining .then functions Long Version: I have 4 async ...
0
votes
2answers
39 views

System.isScheduled() not working in Scheduler/Batch

I have a Scheduler class which executes a batch class. I also execute this batch class from a VF page. Deep down in the class hierarchy, I want to check if this batch was called from a Scheduler or a ...
3
votes
1answer
85 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 ...
1
vote
1answer
166 views

Why isn't my platform event chain working?

I've create the following method: //@NotForProduction public class TEST_SandboxDataFactory { public static void create() { List<String> sObjectTypeNameList = new List<String>()...
0
votes
1answer
42 views

Why isn't my Queueable chain working?

I have the following class, none of the dependencies invoke Queueable: public class TEST_SandboxDataFactory { public static void create() { List<SObjectType> sObjectTypeList ...
4
votes
1answer
58 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 ...
0
votes
0answers
10 views

How come my enqueued class is still getting executed in my unit test when I never call start/stopTest methods? [duplicate]

Per salesforce docs (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_tools_start_stop_test.htm): All asynchronous calls made after the startTest method are ...
4
votes
0answers
48 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 ...
3
votes
1answer
67 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 ...
2
votes
0answers
37 views

Why use Change Event triggers over existing async methods? [duplicate]

When and why should we use Change Event Triggers over @future or queueable methods? Also do they use sync or asynch limits? I cannot find any clear documentation stating this.
4
votes
2answers
109 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
207 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
83 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
91 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
95 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
304 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
295 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
31 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
169 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
181 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
207 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 ...
1
vote
0answers
72 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
100 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
167 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
448 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. ...
1
vote
0answers
20 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. ...
7
votes
1answer
1k 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
260 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
259 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
291 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
404 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 ...