Data directive changing field in temp table, not saving to real table

I’m trying to make a directive that updates HDCase.RMANum when an RMA is created for a case. I’ve written the following code in a standard directive on HDCase, with messages to the trace log every step of the way:

Ice.Diagnostics.Log.WriteEntry("Walrus Start");
using (System.Transactions.TransactionScope txScope = Erp.ErpContext.CreateDefaultTransactionScope())
{
foreach (var ttHDrow in ttHDCase)
{
Ice.Diagnostics.Log.WriteEntry("Walrus HDCaseNum " + ttHDrow.HDCaseNum);
int HD = ttHDrow.HDCaseNum;
foreach (var RMA_iterator in Db.RMAHead.Where(RMA_row=> RMA_row.HDCaseNum == HD))
{
ttHDrow.RMANum = RMA_iterator.RMANum;
Ice.Diagnostics.Log.WriteEntry("Walrus RMANum " + ttHDrow.RMANum);
}
}
Db.Validate();
txScope.Complete();
}

In the trace log, the following is posted after an RMA is created:

<IceAppServer msg="Walrus Start" />
<IceAppServer msg="Walrus HDCaseNum 3856" />
<IceAppServer msg="Walrus RMANum 29036" />
<IceAppServer msg="Walrus HDCaseNum 3856" />
<IceAppServer msg="Walrus RMANum 29036" />

that RMANum is ttHDCase.RMANum, which is what I thought should be the last step. However, in the database this HDCase’s RMANum field is still 0. What step am I missing here?

Standard transaction executes after data being saved to database, if you want this to be modified on the database you have to make it In-Transaction.

Nice! That got it working. Thanks!