Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When i manually delete the opp line item schedules from the layout the quantity field of opp line item doesn't get affected(it doesn't become zero).

Where as thru my apex code it deletes the schedules and setsthe line item quantity to '0'.

What is the reason and How to resolve it?

Thanks in Advance.

share|improve this question
up vote 2 down vote accepted

From the OpportunityLineItemSchedule documentation under the Effects on Opportunities and Opportunity Line Items heading.

Deleting an OpportunityLineItemSchedule decrements the OpportunityLineItem TotalPrice by the deleted OpportunityLineItemSchedule Quantity or Revenue amount.

The Opportunity Amount is also decremented by the OpportunityLineItemSchedule Quantity or Revenue amount, and the Opportunity ExpectedRevenue is reduced by OpportunityLineItemSchedule Quantity or Revenue amount multiplied by the Opportunity Probability.

Also under Deleting an Opportunity Line Item Schedule:

Deleting the last remaining schedule will set the corresponding HasQuantitySchedule or HasRevenueSchedule flags (or both) to false on the parent line item.

So the behaviour you are seeing when deleting the the OpportunityLineItemSchedule records from Apex sounds correct. The OpportunityLineItem Quantity will decrease.

You would need to increment the OpportunityLineItem Quantity again in apex code after deleting the OpportunityLineItemSchedules.

share|improve this answer
If i delete all the schedules from UI its not setting updating the lineitem quantuty. Whats the reason ? – Keepcalmncode Dec 19 '12 at 9:27
@VipulReddy From your description, it would appear that the UI will automatically reallocate the Quantity to the OpportunityLineItem. I'd suggest capturing the debug logs for both as they will show you exactly what is happening. – Daniel Ballinger Dec 19 '12 at 19:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.