Key fields do not become read only when record is saved

If you add a new record via the UI, the key feilds become disabled after you save the record. I am creating a new record via code, the record is created and saved OK, but the key fields do not become read only.

bool result = oTrans_adapter.GetaNewUD100();
						if (result)
							var newSpecID = Guid.NewGuid();
							var row = oTrans_adapter.UD100Data.UD100.Rows[0];
							row.ItemArray = MachineSpecCopy;
							row["Key1"] = dlg.Key1.Text;
							row["Key2"] = dlg.Key2.Text;
							row["Key3"] = dlg.Key3.Text;
							row["Key4"] = dlg.Key4.Text;
							row["Key5"] = dlg.Key5.Text;
							row["Character10"] = newSpecID;
							this._edvUD100.Notify(new EpiNotifyArgs(this.oTrans, this._edvUD100.Row, this._edvUD100.Column));

Not only that, but it seems to break the form. If I load a different record the key fields are not read only then either.

By “Read Only”, are you referring to the ability to change the data in the database, or that the field allows a new value to be entered?

For example, the Order Entry form uses the OrderNum as the key field. After loading a an Order, you cannot change the Order number of that record. But you can type in the OrderNum field, which doesn’t change the fields value of the current record, but rather fetches a different record.

I just mean the UI lets you type in new values - if you change the last key field it asks if you want to create a new record. This is fine behavior for when no record is loaded, but the normal behavior for the form (UD100) is that these fields are read only for existing records.

So I though perhaps I was creating the record wrong or updating the UI incorrectly. Does my code look like the correct way to do this?

The UD forms can behave kind of weird. I would use a row rule to just set those fields as read-only with ext props and use a custom condition for rowmod != A