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
lalilali 

​Lightning app - only one serverside call works.

Hi,
I created expense tracker app in my orgnization just like it is given in the Lightning component Developer Guide.
When I ran the application I was able to see all the Expenses from the Expense object - as expected.
Enter  a new expense and cliking on the submit button doesn't create an expense record. - reason found after debugging is 
the action.setCallback(this, callback) is not being executed  

if I comment the action.setcallback  in getexpenses and then try to execute the  action.setCallback(this, callback) in create expense then it works.

So what I understodd finally is that only calling the serverside call once worked but the second time it doesn't do anything.
Is there something in my org that I need to enable to get the full version of the lightning  to work?

Thanks in advance. 
Gaurav KheterpalGaurav Kheterpal
Do you mind posting your full code? You should be checking for callback as shown in this example
 
upsertExpense : function(component, expense, callback){
        var action = component.get("c.saveExpense");
        action.setParams({
            "expense":expense
        });
        if(callback){
            action.setCallback(this,callback);
        }
        $A.enqueueAction(action);
    }
})
You may want to refer to the official documentation (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/apex_records.htm)and this thread (https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AndMIAS) which explains this in more detail.

If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others and improve the overall quality of Discussion Forums.

Gaurav Kheterpal
Certified Force.com Developer| Salesforce Mobile Evangelist| Developer Forums Moderator| Dreamforce Speaker