Copying or Duplicating a record in ax 2012 using X++

Using this code we can copy records and insert into the same table again. (ie) you can duplicate records

static void BillTableCopy(Args _args)
{
Bill_TabMethod bill_TabMethod1;
Bill_TabMethod bill_TabMethod2;
bill_TabMethod1 = Bill_TabMethod::find(‘Johnkrish’);
ttsBegin;

bill_TabMethod2.data(bill_TabMethod1);

if (!bill_TabMethod2.validateWrite())
{
throw Exception::Error;
}
bill_TabMethod2.insert();

ttsCommit;
}

Advertisements