ApexSensei

Drills DML operations

Update a tagged Account

update saves changed fields on a record that already has an Id.

Your task

Update one tagged Account's Description and read the database before and after to prove the change.

String tag = 'AS-UPDATE-' + UserInfo.getUserId() + '-' +
    String.valueOf(Datetime.now().getTime());
Account acct = new Account(Name = tag, Description = 'Pending');
insert acct;
Id originalId = acct.Id;

List<Account> saved;

Requirements

  1. update acct; should be present
  2. Id = :originalId should be present
  3. Description = 'Reviewed' should be present before update and the query by Id
  4. The value before the update should be printed as Before update: Pending
  5. The new Description should be printed as After update: Reviewed
  6. The updated row should be printed as Updated count: 1
  7. The tagged Name should be printed as Name still tagged: true

Sign in to open this drill