public string CheckReceiptTotal(Decimal? ReceiptAmount, DataSet dsReceiptDetails) { string message = null; Decimal sumAmountReceived = 0; foreach (DataRow Row in dsReceiptDetails.Tables["ReceiptDetails"].Rows) { sumAmountReceived += (Decimal)Row["AmountReceived"]; } if (sumAmountReceived != ReceiptAmount) { message = "The sum of the Split Amount values does not match Total Amount Received"; AddErrorProviderBrokenRule("AmountReceived", message); } return message; }In ReceiptDetail.Partial.cs I added a new property:
public Decimal ParentReceivedTotal = 0;and created this hook override which sets the property when saving to the value entered on the Parent BO:
protected override void HookParentPreSaving(mmBusinessObject bizObj, mmBusinessStateChangeEventArgs e) { Receipt oParent = bizObj as Receipt; ParentReceivedTotal = oParent.Entity.ReceiptAmount; base.HookParentSaving(bizObj, e); }Then in ReceiptDetailRules.cs I added this code to the CheckRulesHook just prior to the return statement:
if (this.ErrorProviderBrokenRuleCount == 0 && entityList.Count > 0) { ReceiptDetail oReceiptDetail = (ReceiptDetail)this.HostObject; ReceiptDetailEntity oReceiptDetailEntity = entityList[0] as ReceiptDetailEntity; this.CheckReceiptTotal(oReceiptDetail.ParentReceivedTotal, oReceiptDetailEntity.GetDataRow().Table.DataSet); }I hope this helps someone else.