You need to sign in to do that
Don't have an account?
mavs
Object Id after Insert
I know this is simple....not sure where i am doing wrong. Any input???
Basically i need the accountid that is just created.
Account a=new Account(); a.type='New'; a.Phone='1234567890'; insert a; if(a.isSuccess) { System.debug(a.getId); }
insert a;
system.debug(a.id);
if the insert fails, it throws an exception.
Thanks simon.
So we cant check if the insert is success or failure.
ok i will add some exception handling.
Wrap it in a try catch block or use the database insert method if you need to verify success.
try{ insert a; }catch(DMLException e){ //TODO Error handling }
Database.saveresult sr = database.insert(a); if(sr.isSuccess()){ //process for success }