Transaction Scope in UD01 Form Customization

I there a way to create/call a transaction scope in a form customization for UD tables?

What I’m trying to do is provide our Engineering team a way to “engineer a part” in UD01 before making it an official record in the [Erp.Part] table. Yes, the Engineering team could create the part as an “inactive” part record and then make it “active”… but this is the way they’ve asked me to do it. So, the idea is to build the part record in UD01, then when the part is approved by our Engineering team, a button-click on the UD01 form customization would create a new record in [Erp.Part] using the field data derived from UD01.

What I would like to do is create a transaction scope for the “UD01-to-Erp.Part” data copy process.

I have tried to call a transaction scope from the UD01 customization, but the errors I receive indicate that I do not have the proper assembly reference in place. My references are the following:

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

… and my call looks like this:

using(var txscope1 = IceDataContext.CreateDefaultTransactionScope())

… and I receive the following error:

The name 'IceDataContext' does not exist in the current context

I have also tried the following:

using(System.Transactions.TransactionScope txscope1 = IceDataContext.CreateDefaultTransactionScope())

… which yields an assembly reference error:

The type or namespace name 'Transactions' does not exist in the namespace 'System' (are you missing an assembly reference?)

A comment in this thread seems to indicate that the transaction scope is not available in a UD customization? If so, what are my options to accomplish a “UD01-to-Erp.Part” data copy?

I don’t believe you can create a new scope in a UI form, nor would you want to. What are you trying to accomplish with a new scope? If you simply call the adapter/BO it will handle the work for you

With the data copy from UD01 to Erp.Part, I wanted to make sure that the process is rolled back should any data-specific errors occur during that copy.

you could always handle the rollback on the method directive level of UD01. So, use the UI to create the UD01 record, then post processing on update (or whatever), you attempt to create a part via a BPM and handle the rollback there, rather than in your UD form. So that way, you create the UD01 record always, and the part sometimes (probably always though too)

Thanks, Aaron. I’m going to try to work through that right now. I’ll let you know here in the post how things are going.

I’m a bit more confused, it seems.

I already have the record created in UD01 (using the “App.UD01Entry.UD01Form” customization). With the record in UD01 (with the UD01 form customization open), I want to create a new record in the [Erp.Part] table and simply copy the data from UD01 to the Part table. This would be done via custom code on a button that is physically positioned on the “App.UD01Entry.UD01Form” customization.

So, all I’m really trying to do is open the [Erp.Part] table, create a new record in that table, then push the values from UD01 over to that new [Erp.Part] record and save it.

All of this should be conducted from the UD01 customization.

ok, if you want to read a record that is in the form already and create a part from that, simply use the part adapter to create a new part and set the new part fields equal to the UD01 fields for the record in the screen. You’ll use the native UD01 adapter to the form to get the record values.