Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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)

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.