4

I want all of my Account billing addresses to be in uppercase.

I have created a trigger like this:

trigger CleanAccount on Account (before insert, before update){

    for(Account a : trigger.New){

        //simplified for post...
        if(a.BillingStreet != null) a.BillingStreet = a.BillingStreet.toUpperCase();

    }

}

When I change an Account's Billing Atreet from 123 OLD ST to 456 new ave within the ui, it properly saves it as 456 NEW AVE.

However in the Account History it creates 2 records

  1. Changed Billing Street from 456 new ave to 456 NEW AVE.
  2. Changed Billing Street from 123 OLD ST to 456 new ave.

Is there a way to stop a duplicate record from being added to the account history?

I don't even understand why it creates 2 records because it should not be saving the record until the trigger has executed.

(My org exclusively uses Person Accounts and there are no other triggers on the Account object)

1 Answer 1

1

History records are very granular and will track all the changes to a field rather than just the cumulative changes of the User, trigger, and workflow rules. In fact, if you have multiple triggers on Account changing the name or a trigger and a workflow rule you will see 3 fieldhistory records.

There is no way to prevent the duplicate AccountHistory records from being created and you can't perform delete operations on History records so there is no way to get rid of them.

The chatter feed has a more summarized view of the change in a TrackedChange type FeedItem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .