Rec. dilemma
anil_mujagic
Member Posts: 91
Hi everyone!
I have Master and Detail tables...
Master:
Year
Month
Detail:
Year
Month
OtherDetailFields (not relevant for this problem)
.
.
.
I defined recDetail Record variable in Master table which points to Detail table and I want to delete detail records in OnDelete trigger of Master table. Which of following solutions should I use:
recDetail.SETRANGE(Year, Year);
recDetail.SETRANGE(Month, Month);
recDetail.DELETEALL;
or this:
recDetail.SETRANGE(Year, Rec.Year);
recDetail.SETRANGE(Month, Rec.Month);
recDetail.DELETEALL;
or this:
recDetail.SETRANGE(recDetail.Year, Rec.Year);
recDetail.SETRANGE(recDetail.Month, Rec.Month);
recDetail.DELETEALL;
All of them work but which is considered a "Best practice"?
Thanks!
I have Master and Detail tables...
Master:
Year
Month
Detail:
Year
Month
OtherDetailFields (not relevant for this problem)
.
.
.
I defined recDetail Record variable in Master table which points to Detail table and I want to delete detail records in OnDelete trigger of Master table. Which of following solutions should I use:
recDetail.SETRANGE(Year, Year);
recDetail.SETRANGE(Month, Month);
recDetail.DELETEALL;
or this:
recDetail.SETRANGE(Year, Rec.Year);
recDetail.SETRANGE(Month, Rec.Month);
recDetail.DELETEALL;
or this:
recDetail.SETRANGE(recDetail.Year, Rec.Year);
recDetail.SETRANGE(recDetail.Month, Rec.Month);
recDetail.DELETEALL;
All of them work but which is considered a "Best practice"?
Thanks!
Try my NAV Object Comparer: http://www.mibuso.com/dlinfo.asp?FileID=1041
0
Comments
-
They would all work the same (assuming that you're programming this inside the master rec), and I like the second one most for readability. This first parameter is the field of the record variable that you're filtering on, so it's not necessary to specify the rec again.
I always select the field in the object browser's field list, and then I manually type SETFILTER( or SETRANGE(.0 -
DenSter wrote:I always select the field in the object browser's field list, and then I manually type SETFILTER( or SETRANGE(.
You mean "recDetail.Year.SETRANGE("
Wouldn't that require defining additional FieldRef variable?Try my NAV Object Comparer: http://www.mibuso.com/dlinfo.asp?FileID=10410 -
No even I can't get away with incorrect syntax.....

I look up the field in the object browser and select the one I need:MyRec.MyField
Then I put the cursor right after the dot (CTRL+Arrow left) and type:MyRec.SETFILTER(MyField
Then I move the cursor to the end (end key) and type the filter criterium:MyRec.SETFILTER(MyField,'<>%1',SomeOtherRec.SomeField);
That's how I do it. You don't need the MyRec reference, since that is already set with the SETFILTER. I do like to explicitly put the other rec variable reference in there, it is just more readable for me.0 -
By The way, I never use WITH, I absolutely hate that command, it drives me nuts. ](*,)0
-
DenSter wrote:By The way, I never use WITH, I absolutely hate that command, it drives me nuts. ](*,)
I agree WITH you
Thanks for explanations!Try my NAV Object Comparer: http://www.mibuso.com/dlinfo.asp?FileID=10410
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
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 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
