Skip to main content Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.
I am trying to create a simple visualforce email template that shows information from opportunity and opportunity field history, but struggling with the history fields.. Please can someone help me with the code?

The email will say..

Please note the revenue on this opportunity was updated. Changed Amount from xxx (old value) to xxx (new value).

Account name:  {!Account.Name}

Opportunity type: {!Opportunity.Type}

Opportunity owner: {!Opportunity.OwnerFullName}

Opportunity Name: {!Opportunity.Name}

Closed Date: {!Opportunity.CloseDate}

Total Amount: {!Opportunity.Total_Amount__c}

To see the old value, please click here- {!Opportunity.Link}

Many thanks,

Swapnil
6 answers
  1. Nov 6, 2015, 3:54 PM
    Swapnil,

    The Opportunity History object contains the values you are looking for.  Example code:

    <apex:repeat value="{!relatedTo.OpportunityHistories}" var="history">

        On {!history.CreatedDate}, Amount was changed to {!history.Amount}.

    </apex:repeat>
Loading
0/9000