function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Moshe BaitelmanMoshe Baitelman 

Process results of a callback function after response

Building my first Lightning component to go on a record details page in Communities.

I have to calculate 3 values. 2 are calculated in the doInit function in the controller with callback functions. The third is the sum of the first two.

I tried writing another function to calculate the 3rd value, calling that function in the callback response but I get an error that the function is not defined. 
Please see controller code provided
({
	doInit : function(component, event, helper) {
        // define recordid
        var recordId = component.get("v.recordId"); 

        // Create actions
        var action1 = component.get("c.getShipmentCost");
        action1.setParams({ wamshipment : recordId });
        var action2 = component.get("c.getFulfillmentCost")
        action2.setParams({ wamshipment : recordId });
        
        // Add callback behavior
        action1.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.shipmentcost", response.getReturnValue());
            } else {
                console.log("Failed with state: " + state);
            }
        });
        
        action2.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.fulfillmentCost", response.getReturnValue());
                // Call function to calculate third variable
                calculateTotal();
            } else {
                console.log("Failed with state: " + state);
            }
        })
        // Send actions to be executed
        $A.enqueueAction(action1);
        $A.enqueueAction(action2);
        
    },
    calculateTotal: function(component, event, helper) {
    	var scost = component.get("v.shipmentcost");
        var fcost = component.get("v.fulfillmentcost");
        var total = fcost + scost;
        component.set("v.totalcost", total);
    }
    
})
(I wouldn't be opposed to moving the functions in the init function to the helper, I just want to get this to work first).
Any help is greatly appreciated!

Thanks!
Zane AileenZane Aileen
A callback function is a function that you pass to someone and let them call it at some point of time. I think people just read the first sentence of the wiki definition: a callback is a reference to executable code, or a piece of executable code, that is passed as an argument to other code lite blue (https://liteblue.me).
Gregory ByronGregory Byron
A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.TCS( https://tcswebmail.co/)
Ansh MalikAnsh Malik
To solve out you must define the value of 2nd and 3rd functions. I still got the error as call back function is a function that is to be executed after another function has finished executing — hence the name ‘call back’.I  tried this on this website (http://watchallanime.com/ (https://watchallanime.com)) but after executing another function.
vinnie kafevinnie kafe
If we run the code multiple times, we may get different results each time. ... The only way to schedule code after promise , is to attach a callback via then . 
http://nbiclearance.website/
ki ftki ft
flower, sometimes known as a bloom or blossom, is the reproductive structure found in flowering plants (plants of the division Magnoliophyta,
tcs webmailtcs webmail
TCS Webmail (https://tcsmail.website/) – Tata Consultancy companies or TCS is Consultancy office who best in their field and do awesome work for their client..
halak desaihalak desai
UIDAI Aadhar Card Download Online (https://uidaiaadharcard.online/)– We provide an informative helpful guide about UIDAI Aadhar Card and many other facilities related to Aadhar Card. aadhar card download by name and date of birth (https://uidaiaadharcard.online/download-e-aadhar-card-by-date-of-birth-dob-and-name/)
jhon smith 16jhon smith 16
Mystic Messenger Emails (https://mysticmessengeremails.com) - Here we are provide all information. So Enjoy this article.Mystic Messenger emails guide page you’ll find correct answers to email
kishan suklakishan sukla
Bank Customer Care Numbers (https://bankguideonline.com/) - Find All Indian Bank Customer Care Toll Free Numbers and complain number. Also, Find how to check account balance by missed call alert and SMS.
nbi clearance onlinenbi clearance online
NBI Clearance Online (https://nbiclearanceonline.website/) Application and Renewal are the most topic on this website. To give the best answer to your question regarding the NBI Clearance issue.
iob netbankingiob netbanking
IOB NET BANKING (https://www.iobnetbanking.website/) - Follow these simple steps to register on IOB internet banking mentioned.
njmc directnjmc direct
NJMCDirect (https://njmcdirect.us/) Traffic Tickets Online Payment at official website ere To know and Pay Traffic Ticket In Easily & Also Get More Benefits and Features.
cad logincad login
USA banking and insurance login Information (https://cardlogin.us/) - Describe how to use online banking and insurance systems.
all infoall info
Allinfo.us (https://allinfo.us/) is really a blog that focuses on providing useful and relevant guides and knowledge on acquiring Trending News, Banking Information, Social News.
sean parker 38sean parker 38
In computer programming, a callback, also known as a "call-after" function, is any executable code that is passed as an argument to other code; that other code is expected to call back (execute) the argument at a given time. This execution may be immediate as in a synchronous callback, or it might happen at a later time as in an asynchronous callback. Programming languages support callbacks in different ways, often implementing them with subroutines, lambda expressions, blocks, liteblue (https://liteblueuspsblog.blogspot.com/2020/03/liteblue-usps-login-to-liteblueuspsgov.html) or function pointers.
bank tollfreebank tollfree
Find All Indian Bank Customer Care Toll Free Numbers and complain number (https://banktollfree.xyz). Also, Find how to check account balance by missed call alert
cora dieselcora diesel
So, it is always advised to check the balance of one’s prepaid card in the portal for PrepaidCardStatus (https://prepaidcardstatus.club/). For doing this, we have to log in to the very portal with our security code and the card number. 
mysticmessenger onlinemysticmessenger online
Mystic Messenger Guide will provide you with all the information you want to know about this dating simulation app. Find out what's in it for you! Mystic Messenger (https://mysticmessenger.online/)
faina buffetfaina buffet
Thanks for sharing these stuff with us.(https://azpayslips.co.uk/mymorri-payslip/)
becu onlinebecu online
Becu Guide Tutorial of how you manage Becu Login,Becu hours,Becu routing number,Becu near me,becu online banking, becu customer service - Becu (https://becuguide.online)
Pintu Pintu 4Pintu Pintu 4
Wеll, tоdау I gоt уоu соvеrеd wіth the аnѕwеrѕ thаt wіll hеlр уоu to раrtісіраtе іn thе Foot Action Guest Feedback Survey.

https://onlinesurvey.onl/www-fapulse-com/
amelia amiamelia ami
This is really very useful platform...Thanks for sharing (https://www.payslipviews.co.uk/nandos-payslip/).
helan disuzahelan disuza
If You’re looking For Miracast For PC Then You Are At Right Place Because In This Article I Have Written About How To Download Miracast For PC. (https://footybitez.com/)
ada smith 5ada smith 5
Thanks for this helpful guide. I really great to have this.
https://www.payslipx.co.uk/oursainsburys-login/
ada smith 5ada smith 5
I think people just read the first sentence of the wiki definition: a callback is a reference to executable code, or a piece of executable code, that is passed as an argument to other code mymorri https://epayslipx.co.uk/mymorri/
Joseph Pop 2Joseph Pop 2
A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action. Learn More Here About UPS Benefits Resource Center (https://upserscomlogin.online/ups-benefits-resource-center-upsers-com/)  & UPS Teamsters 401K Plan (https://upserscomlogin.online/ups-teamsters-401k-plan-eligibility-and-enrollment-upsers-com/) At https://upserscomlogin.online
Joseph Pop 2Joseph Pop 2
I think people just read the first sentence of the wiki definition: a callback is a reference to executable code, or a piece of executable code, that is passed https://upserscomlogin.online/buy-ups-uniform-ups-uniform-store-upsers-com/
Joseph Pop 2Joseph Pop 2
Maybe This Can Solve - Call Back Function (https://personalfinanceadvisor.online)
And If Above Link Is Not Working Check Here - Call Function FIX (https://personalfinanceadvisor.online/financial-apps/how-to-use-mint-budget-app-effectively-best-personal-budget-app/)
Joseph Pop 2Joseph Pop 2
Not Possible At All But If You Have Guts You Can Make It Possible https://upserscomlogin.online/liteblue-usps-employee-login/
Joseph Pop 2Joseph Pop 2
Is It Still Useful To Perform This Task - https://upserscomlogin.online/feed-kroger-login/
upsers empupsers emp
a piece of executable code, that is passed upsers.com login (https://upsersemp.online/) I think people just read the first sentence of the wiki definition
UPS Customer Care Numbers (UPSers paycheck (https://upsersemp.online/how-to-view-paycheck-in-upsers/)) 
nichola noranichola nora
Basically, UPS (https://upserscom.website/" target="_blank) Is One Of the Most Popular Parcel Service companies. And Many Always Ask About UPS Login (https://upserscom.website/) Many Are Worried About UPS Saturday Delivery (https://upserscom.website/ups-saturday-delivery/) Let Me Tell You UPS IS Delivering Express Deliveries On Saturday If It's Not Festival Holiday Or Also If You want Delivery On Saturday ASAP They Will Charge Extra. UPS Just Launched Their UPS Uniform & Apparel Store And They Are Providing Benefits To Their Employees You Can Avail Benefits From the UPS resource Center also learn about UPS Part-time Benefits (https://upserscom.website/upsers-benefits/). also see 7 Things To Know About Ups Personal Vehicle Driver -Pay, Job (https://upserscom.website/ups-personal-vehicle-driver/" target="_blank)
crerry devitecrerry devite
We provided complete information from multiple sources and sorted them by user interest.

Ally Financial Payoff Address Phone Number
Wayne Rooney 10Wayne Rooney 10

UPS drivers are paid an hourly wage, which can vary depending on a number of factors.
Median Annual Salary: $52,500 ($25.24/hour)
Top 10% Annual Salary: $70,500 ($33.89/hour)
The employment of UPSers (https://upserslogin.net) drivers is expected to grow at an average rate over the next decade.

The need to deliver packages more quickly and efficiently will help to maintain the demand for UPS drivers. However, automation may limit the number of new jobs over the next decade as companies seek to reduce costs by increasing the efficiency of their delivery operations.

upsers empupsers emp
Thanks for picking out the time to discuss this, I feel great about it and love studying more on this topic.  chinchilla tube (https://chinchillatube.com/)