Skip to main content

Posts

Showing posts with the label Passing

Pass Query from dialog to Form and Filter records

Created a Runbase class which has dialog selection using QueryStr. I need to pass this Query range selection to a form and need to filter records based on this query Selection. Call the form by passing the Query selection from the class Args _args; FormRun _formRun; EmplId _empId; ; _args = new Args(); // creating a object for args class _args.name(formstr(xtgCummeInquiry)); // Form Menuitem _args.caller(this); // Form Caller(Current Form is mentioned as this) _args.object(CummeQueryRun.query()); _formRun = ClassFactory.formRunClass(_args); //new FormRun(_args); // Creating object for FormRun _formRun.init(); // Form Initialization for Load _formRun.run(); // Form Run for process _formRun.wait(); // Form Wait for Display and from the called form run method,assign the Query range value to the form datasource public void run() { boolean ret; Query q; DictField dictField; str ...

Argument Passing between Forms in Dynamics Ax 2009

Here a sample code to pass argument to one form to another form and using of Args() class. Steps: 1) Create two Forms named FormA and FormB 2)Use the EmplTable as the Datasource of both forms 3)Design FormA with one Grid and add 4 data fields to the Grid(EmplId,DEL_Name,Grade,EmplStatus…..) 4)Assign the datasource for the grid and the data fields 5)Add a Button in FormA 6)Override the Clicked() method and write the below code: void Clicked() { Args _args; FormRun _formRun; EmplId _empId; ; _empId = EmplTable.EmplId; // Selected employee id in the Grid is assigned to the variable which is pass to the next form _args = new Args(); // creating a object for args class _args.name(formstr(VA_FormB)); // Form Menuitem _args.caller(this); // Form Caller(Current Form is mentioned as this) _args.parm(_empId); // Employee Number is passed to next form[but parm() is not a best practise] _args.record(EmplTable); // Table name is passed _formRun = ClassFactory.formRunClass(_args); //ne...

Passing parameters from Managed code to X++ in dataset

In the user control code behing add an event handler to the CreatingDataSetRun event on the AxDataSource control protected void Page_Init(object sender, EventArgs e) { this.AxDataSource1.CreatingDataSetRun += new EventHandler (AxDataSource1_CreatingDataSetRun); } Set the param value to the event arugments void AxDataSource1_CreatingDataSetRun(object sender, CreatingDataSetRunEventArgs e) { e.DataSetRunArgs.parm = "4000"; } In AOT override or add method in the data set and use element.args().parm() to received the paramter public void executeQuery() { QueryBuildRange custRange; ; custRange = SysQuery::findOrCreateRange(this.query().dataSourceNo(1), fieldnum(CustTable, AccountNum)); custRange.value(element.args().parm()); super(); } You can also pass an Enum. For example void AxDataSource1_CreatingDataSetRun(object sender, CreatingDataSetRunEventArgs e) { e.DataSetRunArgs.parmEnumType = EnumMetadata.EnumNum(this.AxSession, "EPFo...

Passing values between forms

The code of button click event of FormA which calls FormB and passes some parameters to that form. void clicked() { // Args class is usually used in Axapta for passing parameters between forms Args args; FormRun formRun; // Our custom made class for passing complex set of parameters FormBParams formBParams = new FormBParams(); Array items = new Array( Types::String ); int i; ; args = new args(); // Our values which we want to pass to FormB // If we want pass just simple string we can use 'parm' method of 'Args' class args.parm( strValue.text() ); // We also can pass enum value to FormB args.parmEnum( NoYesEnumValue.selection() ); args.parmEnumType( EnumNum( NoYes ) ); // and also can pass a cursor pointing to some record (in our case it is EmplTable ) args.record( EmplTable ); // If we want pass more complex set of parameters we can develop our own class ...

Pass the Data Source records to Class or pass the multiple records to class

http://axhelper.blogspot.com/ 1. Add a action MenuItem in a form as a MenuItemButton. 2.Take a clicked method() void clicked() { MenuFunction mf;Pass the Data Source records to Class or pass the multiple records to class args args = new Args(); ; args.record(Table1); mf = new menufunction(identifierstr(classParmData), MenuItemType::Action); mf.run(args); } 3.Take a class class ClassParmData { Table1 tb1;// table variable declaration } —- public static void main(Args args) { ClassParmData _ClassParmData; Table1 _table1; FormDataSource fds; ; if(args.record().TableId == tablenum(Table1)) _table1 = args.record(); // assigning the selected record fds = _table1.dataSource();// getting the datasource _ClassParmData = new ClassParmData(fds); //passing the datasource records to New() method /*_table1 = fds.getFirst(); // can loop all the record here also while(_table1)//fds.getNext()) { info(strfmt(_table1.Field1)); _table1 = fds.getNext(); }*/ } —– void new(FormDataSource fdst) // receving th...

Argument Passing between Forms in Dynamics Ax 2009

Here a sample code to pass argument to one form to another form and using of Args() class. Steps: 1) Create two Forms named FormA and FormB 2)Use the EmplTable as the Datasource of both forms 3)Design FormA with one Grid and add 4 data fields to the Grid(EmplId,DEL_Name,Grade,EmplStatus…..) 4)Assign the datasource for the grid and the data fields 5)Add a Button in FormA 6)Override the Clicked() method and write the below code: void Clicked() { Args _args; FormRun _formRun; EmplId _empId; ; _empId = EmplTable.EmplId; // Selected employee id in the Grid is assigned to the variable which is pass to the next form _args = new Args(); // creating a object for args class _args.name(formstr(VA_FormB)); // Form Menuitem _args.caller(this); // Form Caller(Current Form is mentioned as this ) _args.parm(_empId); // Employee Number is passed to next form[but parm() is not a best practise] _args.record(EmplTable); // Table name is passed _formRun = ClassFactory.formRunClass(_args); //new Fo...

Passing values between form and class

Class name is EmplDuplication and Form is EmplTable . void clicked() {    MenuFunction mf;    args args = new Args();    ;     args.record(EmplTable);     mf = new menufunction(identifierstr(EmplDuplication), MenuItemType::Action); mf.run(args); } Meanwhile, in the main() method of the EmplDuplication class, we need to put this Axapta x++ code to get the datasource: static void main(Args args) {     EmplDuplication EmplDuplication; EmplTable localEmplTable; ;     if(args.record().TableId == tablenum(EmplTable)) localEmplTable = args.record();     ... }

Passing values between form and class

Class name is EmplDuplication and Form is EmplTable . void clicked() { MenuFunction mf; args args = new Args(); ;   args.record(EmplTable); mf = new menufunction(identifierstr(DASEmplDuplication), MenuItemType::Action); mf.run(args); } Meanwhile, in the main() method of the EmplDuplication class, we need to put this Axapta x++ code to get the datasource: static void main(Args args) { DASEmplDuplication DASEmplDuplication; EmplTable localEmplTable; ;     if(args.record().TableId == tablenum(EmplTable)) localEmplTable = args.record();     ... }