hi. A quick summary of my situation: (using D365FO (Update 7) environment).
Trying to create some data entities on transaction tables (cust/vend trans), to push data incrementally out.
This currently can’t happen because no natural key (those tables use recid which being a system fields isn’t allowed).
Workaround devised:
- New field created (int64)
- Clone recid value into that new field with SQL script (+ job) to populate field with recid.
- Make new index using that new field.
- Make index unique. (synchs fine after above script run)
- Make tables primary index the new index
- For new table entries (inserted records) - Class created with oninserted DataEventHandler similar as below:
[DataEventHandler(tableStr(VendTrans), DataEventType::Inserted)]
public static void VendTrans_onInserted(Common sender, DataEventArgs e)
{
// code to update new index field with recid.
}
This works in the most part, but there are certain situations where duplicate key violations happen. For example, one scenario is probably that the Insert method is bypassed (a doinsert?).
My question - Any ideas where else needs to be altered so that no violations of the index will happen - so that every time a new records is created a unique value is populated into it. It doesn’t matter if its recid or just an incremental number sequence really, as long as its unique so that change tracking will work.
As stated above, its mainly the custtrans, vendtran and taxtrans tables that are the problem.
thanks