How to pass parameter between two forms in Axapta?

How to pass one parameter between form in axapta? I want to start form B from an event with a button pressed in form A and pass ... for example, client ID? How can I read it in the assignment form, possibly in the init method? Thanks

+6
source share
1 answer

1 Method

The easiest way is to transfer the current record. Just change the value of the DataSource control for the example to CustTable if CustTable is in the current Form data sources. Then in the init method of the destination method:

public void init() { CustTable cTable; ; super(); // Check for passed arguments if( element.args() ) { // get record parameter if( element.args().record() && element.args().record().TableId == TableNum( CustTable ) ) { cTable = element.args().record(); } } } 

2 Method

If you still need to pass exactly one .parm () value (or a more complex .parmObject () object), you can do this by overriding the method of clicking the source form button:

 void clicked() { // Args class is usually used in Axapta for passing parameters between forms Args args; FormRun formRun; ; 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( "anyStringValue" ); // Run FormB args.name( formstr( FormB ) ); formRun = classFactory.formRunClass( Args ); formRun.init(); formrun.run(); formrun.wait(); super(); } 

Then in the init assignment form:

 public void init() { str anyStringValueFromCaller; ; super(); // Check for passed arguments if( element.args() ) { // get string parameter anyStringValueFromCaller = element.args().parm(); } } 

I should definitely use only the first method, and only in special circumstances will it come with method # 2 with an overriding button method, because this is one of the default templates for passing values ​​between forms. A more sophisticated example is available at AxaptaPedia.com Passing Values ​​Between Forms

+12
source

Source: https://habr.com/ru/post/919307/


All Articles