Followers

19 September 2018

Update the fields values from one field to another field while click the menuitem button in form AX2012

Update the fields values from one field to another field while click the menu item button in form AX2012 :

1) Create the class
2) Create menu item (Action) and add the created class for menu item.
3) Created menu item attached in form menu item button.
4) override the menu item button for refresh the data source.

Ex Code:

Class:

class PMCopyEquipmenttoCLR
{

}

public void CopyEquipmenttoCLR(Args _args)
{
    PMSubJobLotLevelLines    pmSubJobLotLevelLines, pmSubJobLotLevelLinesloc;
    pmSubJobLotLevelLinesloc = _args.record();

    update_recordset pmSubJobLotLevelLines
              setting Additional4 = pmSubJobLotLevelLines.EquipmentNumber
                 where pmSubJobLotLevelLines.Selected == NoYes::Yes
                        && pmSubJobLotLevelLines.SubJobId == pmSubJobLotLevelLinesloc.SubJobId
                        && pmSubJobLotLevelLines.EquipmentNumber!= "";
}

public static void main(Args _args)
{
    PMSubJobLotLevelLines       pmSubJobLotLevelLines;
    PMCopyEquipmenttoCLR        pmCopyEquipmenttoCLR;
    FormDataSource              PMSubJobLotLevelLines_ds;

    pmCopyEquipmenttoCLR        = new PMCopyEquipmenttoCLR();

    if (_args.record() && _args.record().TableId == tableNum(PMSubJobLotLevelLines))
    {
        pmSubJobLotLevelLines          = _args.record();
        PMSubJobLotLevelLines_ds       = pmSubJobLotLevelLines.dataSource();
        pmCopyEquipmenttoCLR.CopyEquipmenttoCLR(_args);
    }
}


This is the class for menu item button clicked for update the fields from one to another column.

17 September 2018

Copy data from one field to another field in table for selected lines while button clicked in form in AX2012

Copy data from one field to another field in table for selected lines while button clicked in form in AX2012 :

Example Code:

void clicked()
{
    PMSubJobLotLevelLines   tPMSubJobLotLevelLines;
    tPMSubJobLotLevelLines = PMSubJobLotLevelLines_ds.getFirst();
    while (tPMSubJobLotLevelLines)
    {
        if (tPMSubJobLotLevelLines.Selected == NoYes::Yes)
        {
           
            ttsBegin;
            tPMSubJobLotLevelLines.Additional4 = tPMSubJobLotLevelLines.EquipmentNumber;
            tPMSubJobLotLevelLines.update();
            ttsCommit;
        }
            tPMSubJobLotLevelLines = PMSubJobLotLevelLines_ds.getNext();

    }
    super();

}