You need to sign in to do that
Don't have an account?
Shubham Sonar
Issue in saving records with ligthning components.
I used the same code as given on trailhead, but either the method that needs to add a record is not getting called or maybe some other reason. The createExpense method is unable to create new Expense in SF object. Can anybody help me out?
Controller.js:
Controller.js:
clickCreateExpense: function(component, event, helper) { if(helper.validateExpenseForm(component)){ // Create the new expense var newExpense = component.get("v.newExpense"); helper.createExpense(component, newExpense); } }
Helper.js:
createExpense: function(component, expense) { var action = component.get("c.saveExpense"); // call to controller method //set parameter value of that controller action.setParams({ "expense": expense }); action.setCallback(this, function(response){ var state = response.getState(); if (component.isValid() && state === "SUCCESS") { var expenses = component.get("v.expenses"); expenses.push(response.getReturnValue()); component.set("v.expenses", expenses); } }); $A.enqueueAction(action);Apex Controller:
@AuraEnabled public static Expense__c saveExpense(Expense__c expense) { system.debug('saveExpense'); // Perform isUpdatable() checking first, then upsert expense; return expense; }
can you please share your all component code.
thanks