function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Moe ZounMoe Zoun 

How to track field History on Opportunity Line Items in PE?

I am trying to track Opportunity field history in Opportunity Products but I am experiencing limitations in Salesforce Professional Edition. Let's say I want to track the Schedule Amount in the Opportunity Product and report changes in the change in Revenue is > $1 mil over the past week.

I'd want to track the current value, the previous value and the date changed. 

I have read that you can create a custom object that can have all this info, but I need some guidance in creating this. Do I need to create triggers as well? I am not sure if this is possible in PE.

Thanks. 
LBKLBK
Unfortunately, Opportunity Products object is not available for tracking history.

You may need to do it with a custom object and a trigger on Opportunity Products object to populate it.

1. Create an exact replica of Opportunity Products object (with all the fields and a Last Recorded Date Time field and a lookup to OpportunityLineItem record- OpportunityLineItem__c)

2. You will need a AFTER UPDATE trigger to populate this. This trigger will approximately look like this.
 
trigger trackOpportunityLineItemHistory on OpportunityLineItem (after update) {
List<OpportunityLineItem_History__c> lstOLIH = new List<OpportunityLineItem_History__c>();

    for (OpportunityLineItem objOLI : trigger.old){
        OpportunityLineItem_History__c objOLIH = new OpportunityLineItem_History__c();
         
        objOLIH.ServiceDate__c = objOLI.ServiceDate;
        objOLIH.Discount__c = objOLI.Discount;
        objOLIH.LastModifiedBy__c = objOLI.LastModifiedBy;
        objOLIH.Description__c = objOLI.Description;
        objOLIH.ListPrice__c = objOLI.ListPrice;
        objOLIH.Opportunity__c = objOLI.Opportunity;
        objOLIH.Product2__c = objOLI.Product2;
        objOLIH.ProductCode__c = objOLI.ProductCode;
        objOLIH.Quantity__c = objOLI.Quantity;
        objOLIH.UnitPrice__c = objOLI.UnitPrice;
        objOLIH.Subtotal__c = objOLI.Subtotal;
        objOLIH.TotalPrice__c = objOLI.TotalPrice;
        objOLIH.OpportunityLineItem__c = objOLI.Id;
        objOLIH.LastRecordedDate__c = System.now();
        
        lstOLIH.add(objOLIH);
    }
    insert lstOLIH;
}
Please check it for syntax errors when you create your own History object.

4. Make sure you setup a purging mechanism (may be a timed work flow) for old records in this History object, because this trigger will generate a lot of records.

Let me know if this helps.
Moe ZounMoe Zoun
Hi LBK,

Thanks for the detailed response. Looking at the custom triggers, it seems like it is an Enterprise Level Feature. I don't see trigger options for PE. Can you confirm if this is in fact doable in PE?

Thanks again!
 
LBKLBK
Hi Moe,

Sorry. I missed that point in your question.

PE doesn't support APEX code by default.

You can either upgrade it to Enterprise Edition (you may not be ready for this yet) or make this trigger as part of a managed package.

But unfortunately, both are going to cost you lot of money.

Can you reach out to your Account Manager at Salesforce to figure out if APEX feature can be bought separately for your ORG?

Back in the days, we were able to buy features like Workflow, etc.

I am sorry for not able to help you more. Hope your Account Manager can.
Moe ZounMoe Zoun
Hi LBK,

Thanks for your reply. Is there a workaround using Workflows? I know SF PE has a limited amount of workflows but we can always purchase this plugin as well: https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B4NIeEAN

Maybe that can work?
 
LBKLBK
There are limited capabilities to do so using flow triggers.

However, I am not sure how it works in PE.

Please check the URL below.
https://developer.salesforce.com/forums/?id=906F0000000AnW1IAK
Dan Cline 1Dan Cline 1
Hi LBK, 

This has been super helpful!! Can you go into more detail on this:

4. Make sure you setup a purging mechanism (may be a timed work flow) for old records in this History object, because this trigger will generate a lot of records.

Thanks,
Dan