New function ASSERTERROR

Belias
Member Posts: 2,998
hi everyone, i noticed that there's this new function:
http://msdn.microsoft.com/en-us/library/ee414211.aspx
i was wondering if someone of you have an idea on how to use this function (except for testing).
In other words...how can it be used "improperly" to skip errors (maybe this function can replace the "IF Codeunit.run then begin" construct)?
http://msdn.microsoft.com/en-us/library/ee414211.aspx
i was wondering if someone of you have an idea on how to use this function (except for testing).
In other words...how can it be used "improperly" to skip errors (maybe this function can replace the "IF Codeunit.run then begin" construct)?
0
Comments
-
Belias wrote:...In other words...how can it be used "improperly" to skip errors (maybe this function can replace the "IF Codeunit.run then begin" construct)?
Imagine you try to SETFILTER(integerfield, UserInput) in your code, and user put '100*' in UserInput field. This will give you error message. Checking UserInput syntax before SETFILTER is possible but quite hard to do (not in case '100*', but normally filter expression can be complicated and painful to parse). Perhaps with ASSERTERROR you can intercept the error and correct user input without the need of analysing filter syntax..
Just a guess - I haven't tried yet.
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
I Guess your problem will be, that if the statement after ASSERTERROR doesn't fail, then ASSERTERROR fails.
I would claim that the value of the function is limited to test.Freddy Kristiansen
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.0 -
Hmm,
How about :PROCEDURE CheckFilter(UserFilterText) SETFILTER(someintegerfield, UserFilterText); ERROR('Filter OK'); END;
somewhere else in the code:ASSERTERROR CheckFilter(UserFilterText) ; IF GETLASTERRORTEXT <> 'Filter OK' THEN BEGIN handleBadFilterStringHere END;
Will this work ? (I'm asking as I don't have NAV2009 SP1 installed yet)Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Yes, it looks like it will work. I just tried it in NAV 2009 Sp1
ASSERTERROR catches the error. :-k0 -
Good catch - I stand corrected #-oFreddy Kristiansen
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.0 -
Well then ASSERTERROR seems to be perfect solution to catch and handle OCX and automation object errors, which are normally a big pain in the a...
Also perhaps for silent ROLLBACK:
PROCEDUE Rollback()
ASSERTERROR ERROR('');
END:
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
This is very good news – great work Slawek and Rashed! =D>
The old IF CODEUNIT.RUN structure had two often unwanted characteristics:
1) It didn’t allow any open (un-committed) transaction before the call.
2) It either did a COMMIT or a ROLLBACK after the codeunit was executed.
Does the ASSERTERROR have the same characteristics?Regards
Peter0 -
Difference from Codeunit.RUN is, that if the command after ASSERTERROR doesn't fail, the ASSERTERROR will fail, it means that it is not there to prevent error, it is there to assume error and if the error is not there, it is error... :-)
More about using this function can be found on the MSDN or on my blog... ;-)0 -
Slawek Guzek wrote:Well then ASSERTERROR seems to be perfect solution to catch and handle OCX and automation object errors, which are normally a big pain in the a...
Also perhaps for silent ROLLBACK:
PROCEDUE Rollback()
ASSERTERROR ERROR('');
END:
Slawek
Anyway, thanks for your valuable informations: i have a question about the quoted post:
what do you mean for silent rollback?Maybe that you can rollback the transaction until the asserterror error('') and then continue the rest of the process?0 -
what do you mean for silent rollback?
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
kine wrote:it means that it is not there to prevent error, it is there to assume error ...Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Slawek Guzek wrote:what do you mean for silent rollback?
Slawek
Thanks for the blog kine, I'll take a look at it ASAP
P.S.: you can find the link to the MSDN in the first post0 -
I've finally installed NAV2009 on my PC and make a few tests of ASSERTERROR and potential 'improper' use..
Proposed Rollback() function works as expected, however it has side effects.
Test procedure looked like this:MESSAGE('Before insert: %1', T97.COUNT); T97.INIT; T97."Table Name" := T97."Table Name"::"G/L Account"; T97.INSERT; MESSAGE('After insert: %1', T97.COUNT); Rollback(); MESSAGE('After Rollback: %1', T97.COUNT);
Rollback did rolled back change made to Table 97, but also suppressed all messages.
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
[Topic moved from 'NAV 2009' forum to 'NAV Tips & Tricks' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
OK I think what's going on here is basically Microsoft is trying to make a Unit Testing framework for NAV, something like NUnit in .NET. Unit Testing is a fashionable idea, not sure if really useful for customizations but I think for add-ons, for the mission-critical parts of big add-onds can be useful. This is what this is about, this is also what this is about: http://www.mibuso.com/dlinfo.asp?FileID=1154
You can read about the concept of Unit Testing here: http://en.wikipedia.org/wiki/Unit_testing
And you can see a quick NUnit example because most likely NAV's testing functions are evolving towards this direction http://en.wikipedia.org/wiki/NUnit#Example0 -
there's a (still) undocumented (and not very well designed :whistle: ) example about this, from microsoft:
http://www.mibuso.com/forum/viewtopic.php?f=7&t=384940 -
It is (almost) always great with new functionality in NAV, but I don't think this level of unit test is what the channel needs. I would rather have better ability to automate user-interactions. I would really like a tool where I could record a series of clicks and input-values, and then a way to compare selected results with the expected results.
This provided kind of unit testing is close to useless in the NAV projects I have been involved in. We have tried several visual test tools, but due to the non-standard control handling in NAV we have ended up using people. We have 8-12 testers sitting 3-4 days every half a year to go through our test scripts before we release a major version.
If we could automate this with a proper test tool, we would run it each night, and could quickly find when a change had some unforseen consequenses in other parts of the solution.
But since the ASSERTERROR can't be used for test scripts (imo) it's great it can be used for something else 8)Regards
Peter0 -
You need to take the tool as tool for testing basic functions, not "whole processes". You need to create tests for each function you create, than you can test the solution. You cannot test in a way, that one test function will test if whole posting process is OK. (problem is, that the posting is one big function and creating test which will test this function is too complicated).0
-
kine wrote:You need to take the tool as tool for testing basic functions, not "whole processes".kine wrote:... and creating test which will test this function is too complicated).Regards
Peter0 -
PDJ,
actually I think automated GUI testing is kind of possible with the RTC - I'm thinking along the lines of somehow catching communication between the client and the service layer. If that's somehow caught and logged, then expose pages as web services and just write a program that reads the log and generates a C# program calling those web services. The hard question is how to catch the communication. Is it encoded?0 -
I expect the GUI of the RTC can be scripted like allmost all other standard Windows application. You don't need to use any of the tricks you suggest. The problem with the classic C/Side client is, that is was originally made before Microsoft had windows classes for Windows 95, so Navision Software had to make their own.
None of the solutions I'm working with are converted to the RTC. Our customers are more focused on our added functionality and the overall productivty of their users, than upgrading just because MS has released a new GUI. (I know I'm oversimplifying, but I hope you know what I mean 8))Regards
Peter0 -
The problem is that in 2010 you can only get an add-on certified if it's fully working on RTC. At least that's the rumour I have heard, I can't verify this rumour, perhaps you might want try to find out if it's true, you are physically much closer to Vedbaek than I am0
-
Miklos Hollender wrote:The problem is that in 2010 you can only get an add-on certified if it's fully working on RTC. At least that's the rumour I have heard, I can't verify this rumour, perhaps you might want try to find out if it's true, you are physically much closer to Vedbaek than I am0
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