You need to sign in to do that
Don't have an account?
Problem with AccountHandler class
I did this code but developer console says "expecting right curly bracket, found catch". I don't find any missing curly bracket in my code. Please help!
public class AccountHandler {
public static Account insertNewAccount(String AccountName){
try{ Account acct= new Account(Name=AccountName) ;
insert acct;
return acct;
}
}
catch(DmlException e){
System.debug('A DML exception has occurred: ' +e.getMessage());
return(NULL)
}
}
public class AccountHandler {
public static Account insertNewAccount(String AccountName){
try{ Account acct= new Account(Name=AccountName) ;
insert acct;
return acct;
}
}
catch(DmlException e){
System.debug('A DML exception has occurred: ' +e.getMessage());
return(NULL)
}
}
2) There is no ; after null
3) If there are validation rules / required fields your insert will fail.
4) You cannot catch DML exception unless you modify your code to do the insert differently.
Check this : https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_database_saveresult.htm
All Answers
2) There is no ; after null
3) If there are validation rules / required fields your insert will fail.
4) You cannot catch DML exception unless you modify your code to do the insert differently.
Check this : https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_database_saveresult.htm