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)?
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Comments
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.
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
I would claim that the value of the function is limited to test.
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.
How about : somewhere else in the code: Will this work ? (I'm asking as I don't have NAV2009 SP1 installed yet)
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
ASSERTERROR catches the error. :-k
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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.
Also perhaps for silent ROLLBACK:
PROCEDUE Rollback()
ASSERTERROR ERROR('');
END:
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
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?
Peter
More about using this function can be found on the MSDN or on my blog... ;-)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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?
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
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 post
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Proposed Rollback() function works as expected, however it has side effects.
Test procedure looked like this: Rollback did rolled back change made to Table 97, but also suppressed all messages .
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
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#Example
http://www.mibuso.com/forum/viewtopic.php?f=7&t=38494
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
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)
Peter
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Yes, it might be too complicated to be used, but I am more afraid that the tests will be useless. If I (god forbid it) was told to make test-code for each of my functions, I could do it. But it wouldn't say anything about wheter or not the solution works as expected. We would just end up with twice as much code in our test-codeunits as the codeunits we wish to test. It wouldn't make any sense.
Peter
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?
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))
Peter
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog