Transaction Prep

I’m not new to filemaker, or to filemaker record locking, but I am having trouble following the reasoning of exactly what I’m looking at in the “transaction prep”.

I’m looking at, for example, in the “Payments” Create or “Update Payment ( Payment )”

By the time we reach “transaction prep”; the transaction record has already been created and opened in DBTransactions, and clearly the transaction prep stage is linking to the existing payment record, or creating a new one as needed.

If [DBTransactions::PaymentId <> $Id]
Set Field[DBTransactions::PaymentID; $Id]
End If

Set Field [Payment::ONE; 1]
Set Variable [$id_Payment; Value::DBTransactions::PaymentId]
… error handling…

What is the if clause for? I understand what the Set Field inside the if clause is for, but I’m unclear on why you wrapped it in that if clause.

The only time it WON’T run the Set Field inside the if clause is when they are already equal. If they are already equal, i recognize there’s no point in updating since it will have the value it started with, but since its extra code to avoid updating it, why bother?

This should be equivalent:

Set Field[DBTransactions::PaymentID; $Id]
Set Field [Payment::ONE; 1]
Set Variable [$id_Payment; Value::DBTransactions::PaymentId]
… error handling…

Is there some subtle record locking consideration that I’m missing? Is this purely a performance optimization?

I’m also curious why you are using regular fields for these instead of globals in the DBTranscations side? Is there any advantage or element of the design that requires these to be regular fields?