You need to sign in to do that
Don't have an account?
Jefferson Fernandez
Multiple Apex Queries on One JS DoInit Controller Lightning Components
Hi All,
I need to fetch data from multiple apex methods which yield separate and different lists of objects but I only have one DoInit function and one possible object to be passed to $A.enqueueAction(action). If i call the enqueueAction several times each for a different object, it malfunctions.
Can you think of any solution where I can call different methods on the same class and also set different attributes on my components once the data has returned? without the need of havingg to separate each methods to have its own component. I just created one component just for demo purposes to the client and i want to have it worked the soonest. TIA
I need to fetch data from multiple apex methods which yield separate and different lists of objects but I only have one DoInit function and one possible object to be passed to $A.enqueueAction(action). If i call the enqueueAction several times each for a different object, it malfunctions.
Can you think of any solution where I can call different methods on the same class and also set different attributes on my components once the data has returned? without the need of havingg to separate each methods to have its own component. I just created one component just for demo purposes to the client and i want to have it worked the soonest. TIA
here is a trick for you
create property in your controller class and set value to property in singel class method and return the whole class .
now you don't need to create multiple aura:attribute you can access data from direct class type attribute
go to below like for it
https://teachforce.wordpress.com/2016/11/17/how-to-access-apex-class-property-in-lightning-component/
i hope it solve you problem
let me inform if it helps you
thanks
That is a very good solution, I didn't realize you could access the variables like that the same way you can in visualforce. This should prove super helpful
Thanks,