Is this a coding convention IF Rec.GET(x) THEN;

idiot
Member Posts: 651
I'd seen a few databases whose previous customization consultants from different VARs use
IF Rec.GET(x) THEN;
Is this a coding convention for C/SIDE?
Why not just Rec.GET(x); or IF NOT Rec.GET(x) THEN ERROR(errormsg);?
The reason for asking is this would not have been a good coding practice elsewhere.
IF Rec.GET(x) THEN;
Is this a coding convention for C/SIDE?
Why not just Rec.GET(x); or IF NOT Rec.GET(x) THEN ERROR(errormsg);?
The reason for asking is this would not have been a good coding practice elsewhere.
NAV - Norton Anti Virus
ERP Consultant (not just Navision) & Navision challenger
ERP Consultant (not just Navision) & Navision challenger
0
Comments
-
This is basically a lazy way of getting around error messages if a specified primary key doesn't exist. It can be really dangerous if the proper consideration isn't taken.0
-
It is good if you only want some related record and if it is not there, to have empty record (e.g. to show some values from that record on report). But of course, it assume that the record before this code is not initialized, else you will have previous values in the record. It means that it have meanig, but with all consequences...0
-
I sometimes use the technique described by kine.
But if I use it I make sure the record is cleared just before it. Something like this:CLEAR(recTheRecord); IF recTheRecord.GET(.....) THEN ; IF recTheRecord."Some Field" = '' THEN BEGIN // or field "Some Field" is blank or the record does not exist. ... END; ... ...
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Wouldn't this look neater & clearer?
IF NOT recTheRecord.GET(.....) THEN CLEAR(recTheRecord);...
It looks really strange to not have any conclusion after testing for a condition...NAV - Norton Anti Virus
ERP Consultant (not just Navision) & Navision challenger0 -
idiot wrote:The reason for asking is this would not have been a good coding practice elsewhere.
Personally I don't like the IF MyRec.GET THEN; construction, to me it lacks proper design attention. To me when you start using an IF statement, you have to think about actions to take for both the TRUE and FALSE legs.
On the other hand, I've used it from time to time to quicky go around an error message. When in a time crunch you don't always have the luxury to sit and think things through. As long as the code properly handles the situation it's just a means to an end really. Not very elegant, but if it works, it works.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