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
8
votes
1answer
410 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 ...
0
votes
0answers
31 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"></...
0
votes
1answer
46 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....
0
votes
1answer
18 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 ...
0
votes
1answer
44 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); ...
1
vote
3answers
843 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 ...
0
votes
0answers
61 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....
-1
votes
1answer
765 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 ...
1
vote
1answer
91 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 : ...
0
votes
1answer
169 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 = ...
1
vote
1answer
569 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 ...
0
votes
0answers
280 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 ...
1
vote
1answer
40 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 ...
8
votes
1answer
1k 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 ...
2
votes
1answer
1k 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(); ...
0
votes
1answer
223 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 ...
2
votes
1answer
118 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 ...
0
votes
1answer
646 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 ...
3
votes
1answer
1k 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 ...
1
vote
2answers
3k 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(...
0
votes
1answer
114 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, ...
1
vote
1answer
330 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 ...
2
votes
1answer
71 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 ...
3
votes
1answer
2k 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 ...
1
vote
1answer
90 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 ...
1
vote
1answer
200 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 ...
0
votes
0answers
559 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 ...
2
votes
1answer
2k 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'}, ...
0
votes
0answers
96 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 ...
0
votes
1answer
656 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 ...
1
vote
1answer
716 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="...
5
votes
1answer
475 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 ...
2
votes
1answer
989 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=...
1
vote
1answer
435 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 ...
2
votes
1answer
750 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 ...
2
votes
1answer
381 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); } ...
7
votes
2answers
358 views

Do Lightning callbacks (in Promises) get their own scope/governor limits

My apps use promises (using the Lax library) quite heavily and I have seen that different callbacks often produce their own log in the Dev Console. Does this mean that: Each callback gets its own ...
9
votes
2answers
3k views

How to make code which uses Lightning promises look more synchronous

When I read about promises, I see that they should appear as solution to prevent callback hell and pyramid of doom but when I actually try to write a code which would use Lightning promises it still ...
2
votes
1answer
510 views

Why Lightning supports Promises but doesn't support ES6 Generators?

There are several articles which suggest that Lightning support Promises with a polyfill, but still ES6 generators are not supported. Prove me if I am wrong. What is the point of supporting Promises ...
3
votes
1answer
654 views

Promise and access to access=private attributes

I am trying to use Promise to make my code more readable and efficient but I'm stuck with the inability to get/set private attribute values. Consider the following example: <aura:component> ...
5
votes
1answer
122 views

Can a Promise be passed as an attribute of a Lightning Component application event?

I am attempting (but failing - getting undefined when the event is handled) to pass a Promise returned by a lightning:workspaceAPI getEnclosingTabId call as an attribute of an application event. Do ...
2
votes
2answers
741 views

Need help with Promises in lightning

In my Lightning application I need some helpers to make their calls after others have completed, so I'm trying to implement promises to make that happen in my init function: doInit : function(...
2
votes
1answer
506 views

Lightning spinner doesn't show up in Promise setting

In the init() function of my Lightning component <aura:component> <aura:handler name="init" value="{!this}" action="{!c.init}" /> <c:spinner aura:id="spinner" /> ......
19
votes
1answer
7k views

Simple example on how to use Promises to call @AuraEnabled Apex methods?

In the Lightning Component Developer Guide you can find that Promises can be used in Lightning Components and what special things we need to care for to make them work. But there is no fully working ...
1
vote
0answers
185 views

jsforce Apex REST call fails in IE11 only. ES6 Promise support issue?

I am calling a custom Apex REST endpoint from JS in a custom VF component within a VF page using the jsforce library, and everything works as expected in Edge, Chrome, Firefox, but not IE11. It seems ...
3
votes
1answer
464 views

How to return a promise from a component's public method?

Situation I'm calling a public method from a child component. The method runs, but it's supposed to return a promise. Instead, it returns nothing. Code Parent markup: <aura:component> <...
3
votes
1answer
872 views

Using Promises in Lightning components

I'm trying to move a synchronous call in a lightning component to use ES6 promises. I have an API returning an array of JSON objects that is hosted on Heroku and want to call that into a lightning ...
5
votes
1answer
314 views

Storable actions and promises

From the salesforce promise documentation: Don’t Use Storable Actions in Promises The framework stores the response for storable actions in client-side cache. This stored response can ...