You need to sign in to do that
Don't have an account?
A S 31
How to Track field History on Opportunity Line Items?
Is there any way to track the field history in Opportunity line item through a custom code? since there is no standard feature enabled for this object to track field history.
Thanks
Thanks
We can do it using Custom Object and Trigger not with the Standard History Tracking.
Step 1:
Create an object with the name History Tracking
Step 2:
Create a Trigger on object where you want to track fields.
Below is the sample code:
Please do let me know if it helps you.
Regards,
Mahesh
All Answers
We can do it using Custom Object and Trigger not with the Standard History Tracking.
Step 1:
Create an object with the name History Tracking
Step 2:
Create a Trigger on object where you want to track fields.
Below is the sample code:
Please do let me know if it helps you.
Regards,
Mahesh
These instructions are great and were easy to follow. I created the Histroy Tracking object, the custom triggers on my Quote object (replacing Opportunity Product with Quote info) and then put History Tracking on the Quote page layout. However, I am not a developer and when I make a change to the data, it is not recording the history. I am not sure if there is a step I am missing in order to get this to work.
This is one of the triggers. It should be putting a row in History Tracking correct?
trigger QuoteQuoteNameHistoryTracking on Quote (after insert, after update) {
List<History_Tracking__c> hisTrackList = new List<History_Tracking__c>();
//
// Iterate through the Quote Name and create the History Tracking Record.
//
for (Integer i=0; i < Trigger.new.size(); i++) {
Quote newCM = Trigger.new[i];
if(Trigger.isInsert) {
hisTrackList.add(new History_Tracking__c(QuoteID__c = newCM.Id,
Object_Name__c = 'Quote',
Field_Name__c = 'Quote Name',
Original_Value__c = '',
New_Value__c = newCM.Name,
Modified_Date_Time__c = System.now(),
Modified_By__c = UserInfo.getUserId()
));
} else if(Trigger.old[i].Name != newCM.Name){
Quote oldCM = Trigger.old[i];
hisTrackList.add(new History_Tracking__c(QuoteID__c = newCM.Id,
Object_Name__c = 'Quote',
Field_Name__c = 'Quote Name',
Original_Value__c = oldCM.Name,
New_Value__c = newCM.Name,
Modified_Date_Time__c = System.now(),
Modified_By__c = UserInfo.getUserId()
));
}
}
if(!hisTrackList.isEmpty()) {
insert hisTrackList;
}
}