Using Function "StartSession" to Trigger a CU & Performance issues

Mohamed_ZayedMohamed_Zayed Member Posts: 39
edited 2016-06-20 in NAV Three Tier
I want to trigger a CU in another company from C/Al code. The approach which I am using is as follow:

1. I created a CU which Insert a rec for me ----> This is the CU that I want to trigger (It takes a Rec as Parameter)

2. I created another CU which will call the first code unit as follow:


Global variables:


OK --> Type Boolean

Session Event -- >Rec (Table Active Session)

Resulttable -- >Rec that I want to pass

// **************CODE******************

Resulttable.FINDLASt; // Get the last rec in my result table

OK := STARTSESSION(SessionEvent."Session ID", CODEUNIT::"MZA Insert In Table", 'Test Company2',Resulttable);
IF OK THEN
STOPSESSION(SessionEvent."Session ID", '***Rec was Inserted***')
ELSE
ERROR('Session was stoped');

// *******************CODE**************

The issue is that I tried to fire the CU which include the start session function and it always works one time only!!

I have to restart Navision server 1 time before I can fire this CU once again. any idea why the CU is working only 1 times??


PS: The above code works only if I fire it while tracing it with the debugger! if I fire it without tracing it wonot work?? really strange :'( ?

Sign In or Register to comment.