You need to sign in to do that
Don't have an account?
Swapnil Patne
Trying to create a visualforce email template that shows information from opportunity field history i.e. "Changed Amount from xxx to xxx"
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
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
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>
All Answers
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>
Thank you for your reply.
I placed the code inside the email body and tried to save it, but it throws an error message: "Invalid field OpportunityHistory for SObject OpportunityHistory"
<messaging:emailTemplate subject="Change of Opportunity Value Notification" recipientType="User" relatedToType="OpportunityHistory">
<messaging:plainTextEmailBody >
<apex:repeat value="{!relatedTo.OpportunityHistory}" var="history">
On {!history.CreatedDate}, Amount was changed to {!history.Amount}.
</apex:repeat>
This is your new Visualforce Email Template.
</messaging:plainTextEmailBody>
</messaging:emailTemplate>
Swapnil
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}
Swapnil
Now trying to figure out how to get this formula working- https://success.salesforce.com/answers?id=90630000000gqdbAAA (only if you can help)
Swapnil