Skip to main content
3 of 5
added 535 characters in body
martin
  • 12.8k
  • 10
  • 50
  • 75

The problem is that the function in your server-side controller requires an account as input:

public static Account saveAccount(Account acc)

You are setting this parameter on the action, but you are using the value of what is typed into the ui:inputText box, which even if it is an account id, it is not an account object.

var newAccount= component.find("AccountId").get("v.value");
action.setParams({"acc" : newAccount});

Assuming you wanted to query the details of an account based on it's id, you would want to change the method in your server-side controller to accept an Id, perform a SOQL query, and then return the results.

public with sharing class AccControllerClass {
    @AuraEnabled
    public static Account saveAccount(Id acc){
        if (acc == NULL) throw new AuraHandledException('Please input an id');
        Account a = [
            SELECT Id, Name
            FROM Account
            WHERE Id = :acc
        ];
        return a;
    }

}
martin
  • 12.8k
  • 10
  • 50
  • 75