Share |

Monday, March 20, 2006

Pass parameters between objects

Sometimes it is necessary to communicate between objects of Navision with the purpose of transferring additional or complementary information to the called object. The more used option for it is by means pass of parameters, that is, from an object we executed to another object but before we called to a function defined by us.

For example: From the form A we executed form B passing to him some parameters with additional information.

First, in form B we will add a function with the parameters to receive:
SetMyParameters(Param1 : Integer; Param2 : Integer)
MyParameter1 := Param1;
MyParameter2 := Param2;
MyParameter1 and MyParameter2 must be defined as Globals, so that they conserve the value until the object is destroyed.

Add code in event OnOpenForm of form B so check that the vars have the value assigned by means pass of parameters :
Form - OnOpenForm()
MESSAGE('MiParametro1 = %1', miParametro1);
MESSAGE('MiParametro2 = %1', miParametro2);

Second, in form A, and before execute to form B, pass the parameters:
control1000000000 - OnPush()
myFormB.SetMyParameters(1, 2); //Pass parameters to form B
myFormB.RUNMODAL; //The var. MyParameter1 and MyParameter2 have value
CLEAR(myFormB); //The var. MyParameter1 and MyParameter2 NO have value

When execute the line myFormB.RUNMODAL it shown 2 messages inform of value of global vars in form B.

3 comments:

sveivers said...

How can I do something similar. I have a codeUnit which runs a form. In the form therer is set a value, and then when retuirnuing to the CodEuNIT i want to use this variabklevalue set in the form?=

borgy said...

useful !
thanx a lot

Unknown said...

useful !
thanx a lot