Home

Thursday, May 29, 2014

Add Numbers on form through button click with help of class in Ax

1-Create a table Addition
  add three integer fields
  S3Add ,ValueB & valueC.


2-Create a  Addition form
  Add adition table as a data source

create a ActionPane Tab and add a menu item button on it

Take a grid

Drag and drop all fields in grid

3-Create a class with name FormAddition write following code
 class FormAddition
{
    Addition  a,s;
    ValueB    b;
    ValueC    c;
    S3Add     sa;
    Args       args;


}

public void run(RecId _recid)
{
    ;
    ttsbegin;
    select  forupdate a where a.RecId == _recid;
    {
       sa = a.ValueB+ a.ValueC;
       a.S3Add = sa;
       a.update();
       // a.insert();
       info(strfmt("ADD- %1,%2,%3",a.S3Add,a.ValueB, a.ValueC));

    }
    ttsCommit;
    // if u want to update use select forupdate a in line 5
 }

public static void main(Args args)
{
    Addition   ad,adloc;
    Object     Addition_DS;
    FormAddition FormAddition = new FormAddition();
    RecId   recidloc;
    ;


    if (args.record().TableId == tablenum(Addition))
    {
        ad = args.record();
        recidloc = ad.RecId;
        FormAddition.run(recidloc);
    }
    Addition_DS = ad.dataSource();
    Addition_DS.reread();
    Addition_DS.refresh();
}

4-Create a menu item button  with Action Type
callon form with help of meny item button


you can download XPO file from my google drive from this link:Class For Sum







No comments:

Post a Comment