Update Discount Percent On Quote Kit Components

I am trying to update the Kit Components (if it’s component pricing) on a Quote based on a selected value on the parent line. It works fine on Sales Orders, but I have come to learn that quotes aren’t quite as pleasant to work with, for whatever reason.

Changing Discount Percent direcly on the form works fine, but doing so through my customization will only update the Discount Percent but not the Discount. When the Discount Percent changes, the Quote.GetDtlUnitPriceInfo method fires, but it behaves differently when done through the form vs through my customization. Through the form, only the component line is in the dataset, but through the customization, the dataset grows as each component line is modified (and the method is called each time the discount percent changes).

For example:

  • Through the customization, Quote Line 1 is parent to lines 2 and 3. I change Discount Type on 1, which sets the Discount Percent on lines 2 and 3. When 2 is updated, the dataset for GetDtlUnitPrice has lines 1 and 2 in it. When 3 is updated, the dataset has all 3 lines. Discount does not update on lines 2 and 3 at all, but Discount Percent does.
  • Through the form, I change the Discount Percent on line 2 and the dataset for GetDtlUnitPrice only has line 2 in it. The Discount calculates properly.

The relevant code for the customization:

decimal discountPercent = this.GetDiscount(edvQuoteDtl.dataView[edvQuoteDtl.Row]["DiscountType_c"].ToString());
if (edvQuoteDtl.dataView[edvQuoteDtl.Row]["KitFlag"].ToString() == "P" && edvQuoteDtl.dataView[edvQuoteDtl.Row]["KitPricing"].ToString() == "C")
{
	// loop through all SalesKits rows and update discount%
	foreach (DataRowView row in edvSalesKits.dataView)
	{
		row["DiscountPercent"] = discountPercent;
	}
}
else
{
	edvQuoteDtl.dataView[edvQuoteDtl.Row]["DiscountPercent"] = discountPercent;
}

I would be more than happy to expand however is needed. I’ve spent far too many hours trying to figure out what I’m doing wrong.