Showing posts with label copy records in form. Show all posts
Showing posts with label copy records in form. Show all posts

9 Jul 2014

Copying data of one table to another table across the company in AX

//Copying data of one table to another table across the company in AX2009


static void CopyData(Args _args)
{
    TableA                  tableA;
    TableB                  tableB;
    DataArea                dataArea;

    ;

  while select dataArea
     {

        changeCompany(dataArea.id)
        {
            tableA= null;
            tableB= null;
            while select tableA
            {
              tableB.CustAccount        = tableA.CustAccount;
              tableB.ItemCode           = tableA.ItemCode;
              tableB.insert();
            }
        }
     }

      info(strfmt("Mission Accomplished"));

29 Mar 2013

How to copy records in a grid of a form

Here is an example of copying a record from a grid :
In the clicked method of the button

public void clicked()
{
super();
ThyKanbanTable::createCopy(thyKanbanTable);
thyKanbanTable_ds.executeQuery();
thyKanbanTable_ds.last(); // set the cursor at the last record copied
Tab.tab(1); // display the tab number one of the form
}
createCopy is declared under the ThyKanbanTable as following :

public static server void createCopy(ThyKanbanTable _ThyKanbanTable)
{
ThyKanbanTable newKanbanTable;

;

ttsbegin;

newKanbanTable.data(_ThyKanbanTable);
newKanbanTable.KanbanID = NumberSeq::newGetNum(ThyKanbanParameters::numRefKanbanId()).num();
newKanbanTable.insert();

ttscommit;
}

Create number sequence in D365 FO

Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...