Find your content:

Search form

You are here

Is there any way to get changes to OpportunityLineItemSchedule objects?

 
Share

This is kind of a weird request - so bear with me. I need to detect changes in the OpportunityLineItemSchedule. Ideally i'd write a trigger against it but SFDC doesn't allow triggers against this object. I found that you CAN write triggers agains the OpportunityLineItem - as it will update the LastModified field when a schedule is modified, firing the trigger on that item.

However, there doesn't seem to be any way to detect changes in the schedule. My initial thought was to compare LastModified times between the LineItem and the Schedule, but I soon realized that the Schedule doesn't have a LastModified field.

Context: I have a customer that keeps track (at least within SFDC) of payments against the schedule by modifying the Description field on a Schedule object. They want to perform some actions when payments are made. I need to be able to get the amount of the Schedule that was paid. However, with this set up, I can't tell which schedule items were modified (or even if any of them were modified at all).

I realize this isn't an ideal way to track this information but it's not my org so I'm somewhat limited in what I can do.


Attribution to: Ryan Elkins

Possible Suggestion/Solution #1

do they support streaming API for this object, if yes that will be ideal to use in this case.


Attribution to: Prafulla Patil

Possible Suggestion/Solution #2

To really track this information, I think it would need to be held in some other object, like maybe concatenated into a text field on OpportunityLineItem(OLI):

Create a before update OLI trigger that checks for schedule updates, then takes all the Descriptions from the Schedule records (in a fixed order) and populates a text field on OLI: "paid $1000;paid $1100;;;;;". You could even include the record Ids in this field if you need to: "00o000000000123: paid $1000; 00o000000000124: paid $1100;;...". Then you can compare the old value of this text field to the current Description values on the schedules to see which one changed. This assumes that the OLI update does actually happen after the Schedule update, which I'm not sure about but seems likely.


Attribution to: Jeremy Nottingham

Possible Suggestion/Solution #3

Potential Workaround

I've had a simliar requirement and was able to take advantage of the fact most changes (see caveat below) to the OpportunityLineItemSchedule table result in the OpportunityLineItem and Opportunity triggers being fired.

To detect the changes:

  1. Query the old related revenue schedules in a before trigger
  2. Query the new revenue schedules in an after trigger
  3. Compare the old and new revenue schedules for differences

Caveat

In my case, I believe the reason the parent triggers were fired was due to the changes in the schedule causing changes to the line item and opportunity amount. You'll want to test that changes to the description field have the same trigger rollup effect.


Attribution to: Ralph Callaway
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/813

My Block Status

My Block Content