Using Function "StartSession" to Trigger a CU & Performance issues
Mohamed_Zayed
Member Posts: 39
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
?
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
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 326 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions