Unable to create new labor detail row in Epicor customization

124 Views Asked by At

i am doing Epicor customization , i tried to create new row in labor detail table , but it came out this error enter image description here

   LaborAdapter adapterLabor = new LaborAdapter(this.oTrans);
        adapterLabor.BOConnect();
//adapterLabor.GetNewLaborDtl(1109);
bool resultGetNewLaborDtl = adapterLabor.GetNewLaborDtlAttch(1111,217588);;
System.Windows.Forms.MessageBox.Show(resultGetNewLaborDtl.ToString(), "Done");
1

There are 1 best solutions below

0
JosephMoeller On

Method call .GetNewLaborDtlAttch(1111,217588) is attempting to add a record for LaborHedSeq 1111 and LaborDtlSeq 217588 which has already been previously saved to the database and cannot be a duplicate in the current session company.

Based on your note that you are trying to create a new labor detail record, here are some additional issues to point out that should help on your way:

  1. LaborDtlAttch is not the same as LaborDtl and can be used when a LaborDtl already exists.
  2. LaborAdapter is an IDisposable. It is important to wrap this in a using or implement a finally/dispose paradigm to prevent memory leaks.
  3. Adapters store local information in the client which is not written back to the server unless an Update() method is called.
  4. Classic UI customizations are deprecated. Consider simplifying the code used in the customization layer in any required customizations and have any logic that is not related directly to display to be handled using server-side methods, which will still work the same way using the Kinetic UI.

Here is an updated sample of code to get started in creating a new laborDtl record.

int laborHedSeq = 0;
// TODO Retrieve laborHedSeq from UI or lookup active row as necessary
using(LaborAdapter laborAdapter = new LaborAdapter(this.oTrans))
{
    laborAdapter.BOConnect();   
    laborAdapter.GetNewLaborDtl(laborHedSeq);
    Erp.BO.LaborDataSet.LaborDtlRow laborDtl = laborAdapter.LaborData.LaborDtl[laborAdapter.LaborData.LaborDtl.Count - 1];
    // TODO Edit additional fields of the new laborDtl row here
    laborAdapter.Update();
}