Export (0) Print
Expand All
Expand Minimize

SingleInstance Property

Microsoft Dynamics Nav 2009

Sets whether a single instance of the codeunit and codeunit variables are instantiated.

Codeunits

Yes if only one instance of a codeunit that makes it a single instance codeunit is set; otherwise, No. The default is No.

When you set this property to Yes on a codeunit, all codeunit variables that use this codeunit use the same instance. That is, all codeunit variables of this codeunit use the same set of internal variables when the code is running on the same client. The codeunit remains instantiated until you close the company.

The following example shows how you can use the SingleInstance property.

Two forms can connect to the same codeunit.

On Form1:

Codeunit1.SetNumber(100);

On Form2:

Number := Codeunit1.GetNumber();

 MESSAGE(Format(Number));

The SingleInstance property in Codeunit1 is set to Yes. Form1 calls a function on Codeunit1 and sets the parameter to 100. Codeunit1 saves this parameter in a local variable. Form2 is now able to get the parameter value (=100) from Codeunit1. A message is displayed.

Community Additions

ADD
Show:
© 2014 Microsoft