Single Instance on automation Server in Navision 2009

Hi All,

i am working on Navision with .Net where i am trying to have single Instance(till Navision closes) once we establish connection with .Net code.

Issue :

create a code unit : - 50001

on run

IF CreateRTCCOMObject THEN BEGIN
MESSAGE(‘Created’);
END
ELSE
MESSAGE(‘Already Created’);

Function

CreateRTCCOMObject() : Boolean

IF ISCLEAR(RTCCOMObject) THEN BEGIN
IF CREATE(RTCCOMObject,FALSE,ISSERVICETIER) THEN
BEGIN
EXIT(TRUE);
END
ELSE
EXIT(FALSE);
END;

RTCCOMObject : automation server variable

excution : calling from customer / vendor card Button (On push)

Output :

It shows (Created) from both forms

Expected Output :

  1. click from 1st form - message (created) should pop up.

  2. click on 2nd form - message (already created) should pop up

note : i want single instance not recreating it … Actually the instance dies on complete execution of function… .

Have to set property SingleInstance = Yes for codeunit