Skip to main content
added 46 characters in body
Source Link
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){  // this name should be changed since the method isn't saving an account.
        if (acc == NULL){                       // I left it the same just to avoid having to change the lightning component.
            AuraHandledException e = new AuraHandledException('Please input an id');
            e.setMessage('Please input an id');
            throw e;
        }
        Account a = [
            SELECT Id, Name
            FROM Account
            WHERE Id = :acc
        ];
        return a;
    }

}

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){  // this name should be changed.
        if (acc == NULL){                       // I left it the same to avoid having to change the lightning component.
            AuraHandledException e = new AuraHandledException('Please input an id');
            e.setMessage('Please input an id');
            throw e;
        }
        Account a = [
            SELECT Id, Name
            FROM Account
            WHERE Id = :acc
        ];
        return a;
    }

}

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){  // this name should be changed since the method isn't saving an account.
        if (acc == NULL){                       // I left it the same just to avoid having to change the lightning component.
            AuraHandledException e = new AuraHandledException('Please input an id');
            e.setMessage('Please input an id');
            throw e;
        }
        Account a = [
            SELECT Id, Name
            FROM Account
            WHERE Id = :acc
        ];
        return a;
    }

}
added 535 characters in body
Source Link
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){  // this name should be changed.
        if (acc == NULL){ throw                      // I left it the same to avoid having to change the lightning component.
            AuraHandledException e = new AuraHandledException('Please input an id');
            e.setMessage('Please input an id');
            throw e;
        }
        Account a = [
            SELECT Id, Name
            FROM Account
            WHERE Id = :acc
        ];
        return a;
    }

}

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;
    }

}

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){  // this name should be changed.
        if (acc == NULL){                       // I left it the same to avoid having to change the lightning component.
            AuraHandledException e = new AuraHandledException('Please input an id');
            e.setMessage('Please input an id');
            throw e;
        }
        Account a = [
            SELECT Id, Name
            FROM Account
            WHERE Id = :acc
        ];
        return a;
    }

}
added 535 characters in body
Source Link
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;
    }

}

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});

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;
    }

}
added 2 characters in body
Source Link
martin
  • 12.8k
  • 10
  • 50
  • 75
Loading
Source Link
martin
  • 12.8k
  • 10
  • 50
  • 75
Loading