BPM for Receipt Entry - Check Receipt Date

Hi I am trying to create a BPM that raises an error when a user does not enter the ReceiptDate in Receipt Entry. The issue is you have to save the receipt screen to enable you to physically receipt. So it works too early. Because you can’t change the second date (ReceiptDate) till it’s saved, so you end up in a loop where you can’t proceed!

I also tried using code instead and i had the same error.
// Get the current Receipt Header record
var receiptHeader = ttRcvHead.Where(r => r.Company == Session.CompanyID).FirstOrDefault();

if (receiptHeader != null)
{
// Compare the ArrivedDate and ReceiptDate fields
if (receiptHeader.ArrivedDate != receiptHeader.ReceiptDate)
{
// Throw an exception to prevent further processing
throw new BLException(“Arrived Date and Receipt Date must match.”);
}
}

On the other hand, could I change the code to just check if the input ReceiptDate matches the ArrivalDate if not the ReceiptDate should take the value of the ArrivalDate. without raising an exception. Like below

using System;

// Get the current Receipt Header record
var receiptHeader = ttRcvHead.Where(r => r.Company == Session.CompanyID).FirstOrDefault();

if (receiptHeader != null)
{
// Check if ReceiptDate is null or not equal to ArrivedDate
if (!receiptHeader.ReceiptDate.HasValue || receiptHeader.ReceiptDate != receiptHeader.ArrivedDate)
{
// Update ReceiptDate with ArrivedDate
receiptHeader.ReceiptDate = receiptHeader.ArrivedDate;

    // Update the record in ttRcvHead 
    ttRcvHead.Update(receiptHeader);
}

}

You might try changing the condition in your first picture to ‘the updated row’ instead of ‘the changed row’ and see if that does what you want. Changed should (but doesn’t always :confused: ) include Added and Updated.

Thank you @MLamkin Seems to be working now.