Questions tagged [promises]

A Promise object represents the eventual completion (or failure) of an asynchronous operation, and its resulting value.

Filter by
Sorted by
Tagged with
0 votes
1 answer
133 views

this.template.querySelector(...).handleUpdateCase().then is not a function

Hello, I develop a parent LWC which calls a method from a child LWC. Unfortunately, I get this error message: this.template.querySelector(...).handleUpdateCase().then is not a function This is the ...
user avatar
  • 621
2 votes
0 answers
74 views

How run logic after NavigationMixin.Navigate completes

This code works great. this[NavigationMixin.Navigate]({ type: 'standard__objectPage', attributes: { objectApiName: this.selectedObject, ...
user avatar
1 vote
1 answer
615 views

Array keep empty after push object from forEach

I am calling one helper method from another helper method using Promise to wait for the result. I have problem where JsonArray array is empty after pushing object from forEach. Did I miss something? ...
user avatar
  • 13
2 votes
3 answers
386 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 ...
user avatar
  • 392
1 vote
1 answer
114 views

errorCallback not catching exception in child when thrown in apex call promise

I have a web component (lwc) with a child component that makes an imperative server call. When an exception is thrown by the server the parent component is not catching it in the errorCallback. The ...
user avatar
0 votes
0 answers
49 views

Add Parameter to Aura Components Apex Controller

I am relatively new to aura components and am having trouble understanding the interconnectivity between files when using parameters in functions. I added the "enrollmentId" parameter along ...
user avatar
0 votes
1 answer
1k views

CPQ Calculator - asynchronous function returning promise pending instead of a value

In the below code I am making a Server Call using a async/await. Once I get the results I want to process the results and then move along after the .Then statement. The problem seems to be that ...
user avatar
0 votes
2 answers
139 views

Issue with returning a URL from wire method in LWC

In the below method, the getApprovalOrders returns the appURL which then calls this.handleLoad(obj.Id); to get the approval request Id to return the URL ${baseURL}/detail/${this.approvalId}. The issue ...
user avatar
0 votes
1 answer
175 views

Conditional displaying error message in Lightning Accordion

I would like to display an error message regarding on JS promise. My code is this: HTML: <template for:each={test} for:item="test"> <lightning-...
user avatar
  • 185
1 vote
1 answer
211 views

Using Wire in a Child Lightning Web Component

I'm trying to build a TabSet form where each child component is a different form. I would like to use @wire in the child components to grab the object needed for the form. However, I can only get it ...
user avatar
  • 1,298
0 votes
1 answer
991 views

How to wait for a chain of wire adapters to settle before running some logic?

I'm trying to get the timing of some setup code in an LWC to be reliable. The code needs the opportunity record type Id so it can get the correct picklist values. Then with those picklist values (and ...
user avatar
  • 131k
0 votes
1 answer
128 views

LWC When user clicks a checkbox, wait for further clicks before updating the Database - what is the best way to implement?

I'm trying to enhance this already-working component, by replacing the Save button with Auto-save feature. I've simply moved onclick={saveCheckboxState()} from Save button to all lightning-input ...
user avatar
2 votes
2 answers
228 views

Calling two methods in renderedCallback()

In such a situation, is it possible that the result from method2 will be earlier than from method1? renderedCallback() { method1() .then(result => { // ...
user avatar
0 votes
0 answers
179 views

Aura component: Mutiple $A.enqueueAction takes long time

I'm testing a component where I upload a file, convert to base64 and split into several CHUNK Parts send each one to an apex method. This component seems quite common online. Like: https://sfdcmonkey....
user avatar
9 votes
1 answer
624 views

Handle chain of long-running callouts from Salesforce

I have seen Apex Promises, Apex libraries to chain Queueables, read about Continuations but I am still unsure what is the best solution for: run multiple long-running callouts Sequentially (wait for ...
user avatar
0 votes
0 answers
163 views

lightning spinner not working

I'm using a spinner to indicate there is something loading. I added this in the template: <div if:true={pendingAction}> <lightning-spinner alternative-text="Loading"></...
user avatar
0 votes
1 answer
1k views

JS Promise in LWC returning in catch block despite success response from Server side Apex

handleAddRows(event) { if (this.selectedSubjTemplate.length > 0) { this.isLoadingModal = true; createRecord({ quoteId: this.quoteRec, subjTemplates: this....
user avatar
0 votes
1 answer
119 views

LWC import method giving error

I have AuraEnabled method in a following class: public with sharing class HistoryRecordsHandler { @AuraEnabled public static List<HistoryRecordWrapper> getAccountAndContactHistoryRecords(Id ...
user avatar
  • 41
0 votes
1 answer
511 views

calling apex method which does callout returns undefined in LWC while showing the correct result in apex debug logs

I have the following lwc code: import findLocalityApex from '@salesforce/apex/NACController.findLocalityApex' ... findLocality() { console.log('this.lat findLocality' + this.lat); ...
user avatar
  • 466
1 vote
3 answers
18k views

await does not wait for Promise to finish

In my LWC, I am trying to call an Apex method and wait for it to finish. This is what it comes down to: import apexMethodA from '@salesforce/apex/SomeControllerClass.apexMethodA'; export default ...
user avatar
0 votes
0 answers
307 views

LWC Community Navigation and api property with promise

I have a community with two pages, Page1 and Page2. Standard flow is Page1 -> Page2. When loading Page2 directly I can use it with no issues, the problem comes up when I use Page2 coming from Page1....
user avatar
  • 53
1 vote
2 answers
5k views

Error : Value provided is invalid for action parameter 'recordId' of type 'Id' in LWC imperative call to Apex

I have a simple LWC component that shows Contacts of a selected Account, i am calling the Apex method imperatively from my JS code while passing the Account recordId. Here is the Apex method signature ...
user avatar
  • 75
1 vote
1 answer
641 views

How to fire an application event inside a Promise - Aura Component

I am migrating some code from callback to promise, and in the original code we are firing an application event but this is causing the promise to enter in the catch part. Original Code somefunction : ...
user avatar
  • 197
0 votes
1 answer
1k views

Working with rereshApex async call in LWC

I am trying to work with refreshApex call in LWC to get the refreshed values for the wired data. @track records; @wire(getRecords) wiredRecords({error, data}) { if (data) { this.records = ...
user avatar
  • 560
1 vote
1 answer
2k views

LWC: Issue with loading static resources

I've incorporated the code documented in the following article into a new component: Play YouTube Videos Through Lightning Web Components It seems like the two JS files referenced, iframe_api.js and ...
user avatar
0 votes
0 answers
657 views

LWC Feature erring with `Received exception event aura:systemError from server`

I randomly began having a strange error appear that I'm having trouble debugging, all it tells me is: Received exception event aura:systemError from server What I have is a "Reports" LWC ...
user avatar
  • 1,000
1 vote
1 answer
74 views

Server Lightning calls using promises

EDIT: I could not figured out how my code is different from the link you provided and the blog, is that possible to pinpoint what/where i'm doing wrong? I'm trying to wrap my head around with promises ...
user avatar
  • 6,692
10 votes
1 answer
4k views

Chain Apex Methods in LWC

I am having a situation where I'm trying to pop an alert on an opportunity, but it's conditional based on data on the current user, and data on a custom object. I noticed that on refreshes the alert ...
user avatar
  • 1,298
7 votes
1 answer
5k views

How to wait for imperative apex call from a LWC to finish running before executing next line?

I have two methods seen below, the first method is a wired call: @wired (firstMethodCall, {param1: 'test'}) wiredResult(result){ console.log('1'); this.secondMethodCall(); ...
user avatar
0 votes
1 answer
698 views

Using Promises not returning the resolve method in Lightning Component

I am trying to recall the apex method until I get a success response for status of log. Below is the code. checkIntegrationLog function simply check the status of a single Log and I want to call that ...
user avatar
  • 45
2 votes
1 answer
502 views

Lightning Component - promise returned before Apex method is completed

I'm developing a component that calls an Apex method which performs a callout to our integration platform (generates an SAP customer from a salesforce account). The component is a button placed on ...
user avatar
0 votes
1 answer
2k views

Record is not getting deleted from datatable in LWC

I am trying to delete a record based on the row selection in data table in LWC. So when a row is selected, the record Id is pushed to the array selectedIdsArray but I am trying to pass it to the Apex ...
user avatar
3 votes
1 answer
3k views

LWC - Multiple createRecord calls

I have a Lightning Datatable containing possible Opportunities. The user can select which records they wish to create Opportunities and click a button (handleContinue below) which creates new ...
user avatar
  • 65
1 vote
2 answers
5k 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(...
user avatar
0 votes
1 answer
262 views

closeQuickAction does not work using javascript promises

I came across a tutorial to call Apex or SOQL using few lines of code. This code is using javascript promises in the following fashion: ApexHelperController.apxc: ({ apex: function(cmp, method, ...
user avatar
  • 1,458
1 vote
1 answer
664 views

Using LWC and an Imperative APEX method, I cannot reference the parameter being passed into APEX because it is a promise [duplicate]

I have an apex method which receives a country name and returns a country code. @AuraEnabled (cacheable = true) public static String getCountryCode(String searchString) { //TODO add the code to ...
user avatar
  • 11
2 votes
1 answer
123 views

Promises not being awaited when resolved in remoteAction callback

I'm trying to upload an array of files to an s3 bucket. I'm building an array of promises for each file, that generates the pre-signed URL, blobs the file and then does the upload. Each promise should ...
user avatar
3 votes
1 answer
4k views

LWC Imperative Apex and the promise result

In Lightning web components, how can I process the results of an imperative Apex call? Specifically, I want to do some immediate processing if the Apex returns null. However, the result promise ...
user avatar
  • 6,418
1 vote
1 answer
162 views

Reading a file from salesforce aura helper recursion problem

I'm trying to read a file in an async way on aura helper, but recursion is not happening, is just executed once. The code is pretty simple and tried a lot of approaches but no one work. I try with ...
user avatar
1 vote
1 answer
292 views

Errors when using Penpal in Lightning Web Component to call Visualforce page via iframe

I am trying to create a LWC version of Doug Ayers library for doing promise-based service component for calling REST API from Lightning Aura Components. Basically, the LWC communicates using Penpal ...
user avatar
  • 8,380
0 votes
0 answers
1k 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 ...
user avatar
  • 367
2 votes
1 answer
4k views

How do I force a method to wait until a prior method has finished within a lightning controller?

In my controller I have an Init function that looks like this init: function (cmp, event, helper) { cmp.set('v.mycolumns', [ { label: 'Document Name', fieldName: 'Name', type: 'text'}, ...
user avatar
  • 625
0 votes
0 answers
125 views

Component behaves differently in community vs internal

I have a component that displays a modal form using create component and a modal promise. In the community, it works as intended, where something occurs that fires the event that creates the ...
user avatar
  • 311
0 votes
1 answer
1k views

Promise JS to handle Future Callout from Lightning Component

I am using Promise JS in my lightning component to make a server call. The apex class makes a callout to a external endpoint and returns the response to the component. This is working fine. After ...
user avatar
1 vote
1 answer
905 views

Multiple calls to lightning:quickActionAPI getAvailableActionFields() fails

I get an error when doing multiple calls to getAvailableActionFields in a Promise.all(). The markup: <aura:component implements="force:hasRecordId"> <lightning:quickActionAPI aura:id="...
user avatar
  • 233
5 votes
1 answer
666 views

Failing to conditionally render Lightning component after setting value from Promise callback

The Goal I am trying to conditionally render a component after a user successfully uploads a CSV file. Here is the markup for the conditional rendering. Details have been omitted: <!-- Create ...
user avatar
2 votes
1 answer
1k views

$A.createComponent not firing when loading component dynamically

I have a parent custom component which loads child custom components dynamically to create a non linear interview/wizard process. The child component has aura:valueInit method: <aura:handler name=...
user avatar
  • 8,380
1 vote
1 answer
549 views

Error: Definition does not exist on the client for descriptor - when using JavaScript Promises

I am getting this error message when dynamically adding a lightning component: Definition does not exist on the client for descriptor:markup://c:MyCustomLightningComponent. Client side caches ...
user avatar
  • 8,380
2 votes
1 answer
955 views

JavaScript Promise Chaining in lightning component has transaction issue in server side

I have a requirement , where I want to call server methods multiple times passing some value as parameter. I have used javascript promise to call the methods one after another using .then When I am ...
user avatar
2 votes
1 answer
638 views

How to use Promises to kick off one helper method after another one is completed?

I've got these two helper methods: submitBookingInformation: function(component, event, helper) { helper.createLead(component, event, helper); helper.saveRecord(component, event, helper); } ...
user avatar
  • 659