Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Passing Parameters from form to class in AX

(0) ShareShare
ReportReport
Posted on by 578

Hi Experts,

I have a table and form consider as TestTable with 2 fields in it. 

1. Employee (string)

2. Posted (NoYes, Checkbox) 

I am running a batch job through the class named TestClass to process the data if the checkbox is set to No for any record in the table. 

public void run()
{
ttsBegin;

while select forUpdate TestTable where TestTable.Posted == NoYes::No 
{
does the updates here.

}

ttscommit;

If I select only one record in the form and I need to process only that particular record. how the run method should be?. I have created a button in the form to call the class but no idea how to pass the arguments to the class through the clicked method on the button. I need to call the class and process the particular record whenever needed without harming the batch job's usual run. 

Appreciate helping with the clicked & run method sample. 

Thanks in advance.  

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 231,403 Most Valuable Professional on at
    RE: Passing Parameters from form to class in AX

    It depends on which framework was used to implement the batch job.

    If RunBaseBatch, you need to create a variable holding identification of the record, such as RecId. You'll set this variable from _args.record()). You also must add it to CurrentList macro.

    If it's based on SysOperation framework, add a variable and parm* method for RecId to the data contract class and set it in the service controller.

  • Verified answer
    Blue Wang Profile Picture
    Blue Wang on at
    RE: Passing Parameters from form to class in AX

    Hi AX Beginner ,

    Args class is usually used in AX for passing parameters between forms.

    Please read these:

    faizanashraf.wordpress.com/.../

    rohitdynamics.blogspot.com/.../pass-value-from-form-to-class-in-ax-2012.html

    community.dynamics.com/.../passing-argument-from-form-to-class

  • Verified answer
    Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,091 on at
    RE: Passing Parameters from form to class in AX

    Hi AX Beginner,

    1. You should create an action menu item for your runbase class

    2. Add a new action menu item to the form instead of a button

    3. In main method you can get access to the current cursor on the from with Args parameter (_args.record()) and pass it to a class variable via parm method.

    4. Then you can modify your method like

    while select forUpdate TestTable 
        where TestTable.RecId = myTestTestPassedViaParmMethod.RecId //Or use other primary key fields instead of recId
           && TestTable.Posted == NoYes::No 
    {
    does the updates here.
    
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,403 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans