Problem with code/messagebox, can you help?

Imaspal
Member Posts: 68
Hi Experts!
I have a codeunit, that launches few codeunits. If any of these "codeunitlaunches" won't work, description of this "crash" is written to the error log. After "crash" next codeunit will be launched normally.
After a single codeunit is ready, the "Ready"-messagebox appears.
If there is no "crashes", my codeunit works fine.
If "crash" appear to one codeunit, the other codeunits run normally and error log is written ok.
The problem is with messageboxes. The system shows only messageboxes of the performed codeunits that are launched after "crash". It seems to be, that when data is written to the error log, all those messageboxes disappear, that appeared before crash.
Can you help with this problem?
Yours,
IP
I have a codeunit, that launches few codeunits. If any of these "codeunitlaunches" won't work, description of this "crash" is written to the error log. After "crash" next codeunit will be launched normally.
After a single codeunit is ready, the "Ready"-messagebox appears.
If there is no "crashes", my codeunit works fine.
If "crash" appear to one codeunit, the other codeunits run normally and error log is written ok.
The problem is with messageboxes. The system shows only messageboxes of the performed codeunits that are launched after "crash". It seems to be, that when data is written to the error log, all those messageboxes disappear, that appeared before crash.
Can you help with this problem?
Yours,
IP
0
Comments
-
Messages are saved into "stack" and are showed just at the end of transaction. If you have some error, this "stack" can be in your case cleared and thus no messages are showed. It is done in this way to prevent messages to block transactions by waiting for user input (if the message block the transactions, all locks on tables will be there until user click OK on the message and it can be few minutes after...). Try to solve the "messages" in another way. What is the purpose of these messages? Can you do same thing in another way?0
-
Thanks, good questions.
I haven't done those codeunits, so I'm not sure of their purpose. I guess they only report to user, that codeunit have been succesfully performed.
Maybe you can give me a hint of how to do this in other way, if I show you my algorithm?
Algorithm goes like this:No := 1; REPEAT Table.SETRANGE("Order No.", No); IF Table.FIND('-') THEN BEGIN REPEAT IF CODEUNIT.RUN(CodeunitID) = FALSE THEN BEGIN "writing data to error log" COMMIT; END; UNTIL Table.NEXT = 0; END; No := No + 1; UNTIL No >= 5;
Codeunits have to be performed in certain order. This order is in the Table. In this table user can change the order in which the codeunits are performed.
Yours,
IP0 -
May be just instead error when run fails, you can add section which will write "OK" into the log... in this case you will have log for boths - fails and ok runs.0
-
Messages are saved into "stack" and are showed just at the end of transaction. If you have some error, this "stack" can be in your case cleared and thus no messages are showed.
Is it possible to clear this "stack" somehow, for example by code?
Yours,
IP0 -
No, the stack is implemented internaly and you do not have any access to that.0
-
No, the stack is implemented internaly and you do not have any access to that.
So, if I want to clear the stack, I have to make a runtime-error on purpose and pass this error by if-sentence. Is it "clever/normal/acceptable" to make a runtime-error on purpose?
Yours,
IP0 -
It is not "normal" to call error just to clear the message stack... ;-) Primary purpose of Error is to roll-back the transaction, not preventing to show some messages. You can use e.g. singleinstance codeunit to keep the message texts in some temporary table and read and show them when you need... it means "creating some own message stack which you have fully under control"... ;-)0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K 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
- 320 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