Passing Arguments from One Form to Another Form in AX 2012


Article Author : shahab Hayat, Article Posted on : 8/10/2017, Article Category : Dynamic Ax


please share this article to help others :

Here i will explain that how to pass aguments from one form to another in dynamics AX (axapta) 2012.

 

Explaination:

For understanding i have created two tables and two forms for sample as an example.

First i have Createted First Table with name SheetTable and than Second Table name SheetDetails 

after creating tables i created two forms , Form 1 name SheetTable and Form 2 name SheetDetails.

i want to pass SheetId from Form1 (SheetTable) and getting in Form 2 (SheetDetails).

lets start

 

Step1.

Go to AOT > Data Dictionary > Tables  and now click new table and give name.

Table 1: SheetTable

 

 

Step2.

Repeat step1 for creating Table 2.

 

Table 2:SheetDetails

 

 

 

Step3.

Go to  AOT > Forms  select new form and give name.

 

Form 1 :SheetTable , Datasource Name : SheetTable

now in the Data Source of the form just drag and drop table from AOT > Data Dictionary > Tables > SheetTable
Add new Grid control in design and drag and drop fields from data source.

Create Ok Button in SheetTable Form

 

 

create the method as clickable and Write a piece of code in the clicked method of OK button.

 

 

below is the code behind the OK button.

 

void clicked()

{

Args args;

FormRun formRun;

super();

args = new args();
args.parm(SheetTable.SheetId);

args.record(SheetTable);

args.name( formstr( SheetDetails ) );

formRun = classFactory.formRunClass( Args );

formRun.init();
formrun.run();
formrun.wait();

}

 

Step4.

repeat same process as in step3.

Form 2: SheetDetails , DataSource Name : SheetDetails

 

 

 

write a piece of code in Form level init() method

public void init()

{

Query query;

QueryBuildRange qbr;

SheetTable _sheetTable;

SheetDetails sheetDetails1;

Str _parmid;

super();

_sheetTable = element.args().record();

_parmid= element.args().parm();

query= new Query();

qbr=query.addDataSource(tableNum(SheetDetails)).addRange(fieldNum(SheetDetails,SheetId));

qbr.value(_parmid);

SheetDetails_ds.query(query);

}

 

Output:

 

 

 



Related Article


Add your valuable Comments


Success! Comment added successfully.

Name is required

Email is a required field Invalid Email
Message is required

Comments


{{cmt.Item1}}


{{cmt.Item2}}

{{cmt.Item3.slice(0,9)}}


ADS

Tags: