For passing parameters from one form to another a special class Args is usually used.
Example:
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
// just for passing our parameters.
formBParams.parmSomeDate( someDate.dateValue() );
formBParams.parmSomeTime( someTime.value() );
for( i=0; i<ListBox.items(); i++ )
{
items.value( i+1, ListBox.getText( i ) );
}
formBParams.parmItems( items );
// Pass our object to FormB
args.parmObject( formBParams );
// Run FormB
args.name( formstr( FormB ) );
formRun = classFactory.formRunClass( Args );
formRun.init();
formrun.run();
formrun.wait();
if( formrun.closedOk() )
{
answerFromFormB.text( args.parm() );
}
super();
}
Let me try my hand in providing the solution. Here is my approach.
Lets say we have two forms Form1 and Form2 and Form1 is supposed to send four values irrespective of their datatype to Form2. I want to send the values when a button is clicked and I am using clicked under that button.
In Form1(Send)
void clicked()
{
Args args = new Args();
ContainerClass conClass_Obj;
Container conSend;
;