How To Execute The Code After Error Message
lakshman
Member Posts: 44
DEAR ALL,
Please Suggest me how to execute the code ofter error message
without stop the execution.
Thanks & Regards :
lakshman
Please Suggest me how to execute the code ofter error message
without stop the execution.
Thanks & Regards :
lakshman
0
Comments
-
??? Do you know how a error worked :?:
With an error, the DBMS makes a rollback of the current transaction, for example your posting. Why you will stop this and risk inconsistent transactions :?: ](*,) [-XDo you make it right, it works too!0 -
You can use CodeUnit's RUN funtion.
IF CodeUnit.RUN() THEN
MESSAGE('No Error in this')
ELSE
MESSAGE('There was an error');
Of course You lose the rest of CodeUnit.RUN code, but still You are able to handle an error appearance. I don't remember any other way of not stopping Your code. Maybe this will help You.0 -
krzychub83 wrote:You can use CodeUnit's RUN funtion.
IF CodeUnit.RUN() THEN
MESSAGE('No Error in this')
ELSE
MESSAGE('There was an error');
Of course You lose the rest of CodeUnit.RUN code, but still You are able to handle an error appearance. I don't remember any other way of not stopping Your code. Maybe this will help You.
If you take this approach you must also handle the rollback. NAV will see this has a successful transaction and commit any changes.There are no bugs - only undocumented features.0 -
bbrown wrote:krzychub83 wrote:You can use CodeUnit's RUN funtion.
IF CodeUnit.RUN() THEN
MESSAGE('No Error in this')
ELSE
MESSAGE('There was an error');
Of course You lose the rest of CodeUnit.RUN code, but still You are able to handle an error appearance. I don't remember any other way of not stopping Your code. Maybe this will help You.
If you take this approach you must also handle the rollback. NAV will see this has a successful transaction and commit any changes.
But only for what was done before the Codeunit.RUN...0 -
Anothing thing on error handling is that you can actually determine the last error - this is especially useful when working with NAS and there is no user interface but you want to be able to log or otherwise notify an admin of the failure condition.
In version 5.0 of Navision they've implemented GETLASTERRORTEXT and CLEARLASTERROR functions. These can be used in conjuction with the programming patter described here using the IF CODEUNIT.RUN() to return the actual error that would be propagated to the users screen.
This is vastly superior to just logging an error has occurred or trying to guess what could have caused the error.0 -
Dear all,
Actually my requirement is i have emp table with Eno,Ename,salary,post(boolean).i write two codeunits like below
codeunit1
IF Emp1.FIND('-') THEN
REPEAT
IF Emp1.Post=FALSE THEN
IF EmpCu.check(Emp1) THEN
Emp1.Post:=TRUE;
Emp1.MODIFY;
UNTIL Emp1.NEXT=0;
codeunit2
empcu.check(rec);
if emp.sallary=0 then
emp.textfield(salary);
whenever i run 1 st codeunit then it checks post false then call 2nd codeunit .in second code unit checks salary is null then it shows error stop the execution else goes to step.but i need process all records except employee whose salary is 0.
i.e i have 50 employee if 10 th employee's salary=0 then show error and stop the execution but i need process the next employee records also execept 10th employee0 -
Why just do not calc the salary and skip the records with salary 0? Is the calculation of the salary so complex step? Or it is just some field? This way of "catching" error is good when you expect many errors you cannot handle before calling the needed function (like posting function) through code and you can do all the steps as separate transaction.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
