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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s