Question regarding passing parameter between forms

I’ve created 2 forms, A and B. In A i select an employee from its drop down menu and then i clicked on the button there. When i clicked on the button, B will be have 2 text box and it will display the Employee ID and the other will display the Employee name. How can i do that? Thanks in advance.

In the clicked method of the button of formA, you pass the Employee code as parameter to the formB. You can use the following code to do that void clicked() { Args args = new Args(); Formrun frmRun ; super(); args.parm(EmpCode); //EmpCode is a string containing the code selected in the dropdown. args.name(formstr(formB)); args.caller(this); frmRun = ClassFactory.formRunClass(args); frmRun.init(); frmRun.run(); frmRun.wait(); } In the init method of formB you accept the code using following code Getparm = element.args().parm(); Now write select statement to find out Employee name and put it in the Text boxes. Hope this will help you.

Thanks Krish, it works.

Hi, Krishnendu Roy I have another problem,you can pass Only One parameters from form A to form B,But how can I pass two or more parameters to form B???

Hi Andy As per my knowledge, there are two ways to do that 1) Put all the parameters in a string seperated by some special character. Send that as parm. In form B, find out the parameters using substr function. 2) Define a new class. Put all the parameters as variables in the ‘classdeclaration’. In the ‘new’ method of that class accept the variables as parameter and initialise the variables defined in ‘classdeclaration’. In FormA, you instantiate the new class with the parameters and send the instantiated object as parameter using the code args.parmObject(_objectname); In FormB, accept it using the code _objectname = element.args().parmObject(); Now in FormB, get the values of the parameters from the variables defined in _objectname.

HI,Krishnendu, ~~,I do it same to you,and I have another way to pass parameters to another form,That is using temporary table. Becaust there are many advantage using temporary, I can insert many many data to it,and I can use sql to handle the data.

hi Andy How do u handle the multiple user situation using Temp table. Say, u are passing 2 parameters (P & Q) from formA to formB. Two users are accessing the forms simultaneously with different set of parameters. So 1st user store p1 & q1 in the temp table and 2nd user p2 & q2. Now in the receiving end FormB may receive the wrong set of parameters.

quote:


Originally posted by krish_roy As per my knowledge, there are two ways to do that


…or You can use a container.

Hi all, why don’t you call a method on formb? use same code-sample as krish_roy but call after formRun.init() your method on formb. e.g. method that requires 2 or more arguments or container etc. You do not have this method in the selection after you write formRun. but you can just type it and it won’t give you a compilation error. hope this helps

Hello, how do you handle multi select of records this way ?? Thanks

quote:


Originally posted by wassini

quote:


Originally posted by krish_roy As per my knowledge, there are two ways to do that


…or You can use a container.


Hi Wassini, How can we pass multiple parameters between forms using container data type?

HI,Krishnendu Roy About multiple user situation, Axapta can handle it finely for me! Why?Temporary tables are created as files in the local file system.(extract from Developer’s guide).so temporary table is working for per user. And I tested it,It worked fine in mutiple user environment.

Krishnendu Roy: It should be possible to send a container with the args object? Or You can use an array and take a look on the Record2DynaKey. /Lars

Hi Krish, There’s some changes to the customization that i’m doing and i’m stuck. I tried to use the method above and i have a few questions, please read my comments in red font : 1) void clicked() { Args args = new Args(); Formrun frmRun ; super(); args.parm(EmpCode); //EmpCode is a string containing the code selected in the dropdown. (so does this EmpCode is the field that i pass to form B?) args.name(formstr(formB)); args.caller(this); frmRun = ClassFactory.formRunClass(args); frmRun.init(); frmRun.run(); frmRun.wait(); } In the init method of formB you accept the code using following code Getparm = element.args().parm(); (what does this Getparm do? I got an error saying that it’s not declared) Now write select statement to find out Employee name and put it in the Text boxes. 2) I’m going to create 2 forms, Form C and D. In Form C, when i create a new employee, and after that i clicked on the ‘Claims’ button, Form D will be open. In the forms there’s 4 fields : Name, EmplId, Department, and Job position. How can i make it to display the info for the particular employee in form D? Thanks in advance

hi 1) Please tell me whether you have a datasource attached with form A. If it has a datasource attached with it, then write args.parm(datasourcename.FieldName) If FieldName is not string type convert it to String then send. ‘Getparm’ is a string type variable, which is accepting the parameter. You have to define it on the top. 2) What is your exact problem? Are you unable to get the value of the 4 fields in Form D? Or you have got the values of the fields but can’t find the way to display it on the form.

quote:


Originally posted by wassini
Krishnendu Roy: It should be possible to send a container with the args object? Or You can use an array and take a look on the Record2DynaKey. /Lars


Hi Wassini I also thought of using container data type to pass multiple parameters across forms. But can’t find any way to do that. If you have any code for that, could you please forward it. And secondly I cant get any help regarding Record2DynaKey. Please tell me where can I get it. Thanks

Hi Krish, I manage to pass the EmplId from Form C to D. But how come when i click the button to open Form D, the Form D was open twice. What have i done wrong?

I got it already, it’s just that i shouldn’t have use the MenuItem for Form D. As the codes already define which form to open. I created a new button and overwrite the ‘Clicked’ method to call the Form D. I manage to pass the Empl_Name to the form and i managed to select its EmplId with a select statement. But when i assigned it to the fields in the form, it’s not showing, even when i wrote : FormD_ds.refresh(); FormD_ds.write(); what’s wrong?

hi Ken You select a StringEdit control on the form. Set its Autodeclaration property to ‘Yes’. Now in the from code _stringedit.text(_EmpId); Hope, this will help you.

quote:


Originally posted by krish_roy I also thought of using container data type to pass multiple parameters across forms. But can’t find any way to do that. If you have any code for that, could you please forward it.


I haven’t tried to pass multible parameters, but I thought it was possible that way - maybe I’m wrong!

quote:


And secondly I cant get any help regarding Record2DynaKey. Please tell me where can I get it.


There is not much documentation on this, but look in the AOT \Classes\Global\record2DynaKey