What is the output of the following code snippet?l Contact CON = new - ProProfs Discuss
Topics
Products
Follow Us:

What is the output of the following code snippet?l Contact CON = new Contact( LastName = 'JOHNSON', LeadSource = 'Web')23 Savepoint sp = Database.setSavepoint();4 insert CON;5 Database.rollback(sp);67 CON.LeadSource = 'Email'8 insert CON;



A. A runtime error will be thrown on line 5.
B. The contact record will be inserted with Leadsource value Web.
C. A runtime error will be thrown on line 8.
D. The contact record will be inserted with Leadsource value Email.

This question is part of PD2-2
Asked by Pal, Last updated: Jul 31, 2020

+ Answer
Request

3 Answers

Gourav

Gourav , Bangalore

Answered Jun 24, 2020

C. A runtime error will be thrown on line 8.
The ID on an sObject inserted after setting a savepoint is not cleared after a rollback. Create new a sObject to insert after a rollback. Attempting to insert the sObject using the variable created before the rollback fails because the sObject variable has an ID. Updating or upserting the sObject using the same variable also fails because the sObject is not in the database and, thus, cannot be updated.

 

devilzP

DevilzP

Answered Apr 05, 2018

C. A runtime error will be thrown on line 8.

 

Pal

Pal

Answered Jan 18, 2018

A runtime error will be thrown on line 8.
 

Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer

Email Sent
We have sent an email to your address "" with instructions to reset your password.