Expand BOM for all rows in a sales invoice

jukkapalmu
Member Posts: 2
Hello all.
Noob here, so go easy on me. I've a customer for whom I do mostly server and desktop support tasks, and they're using Financials 2.0 (yes, old, but it's working and they're on the cheap end of the scale so don't want to upgrade).
Now there's a new law here, stating that all household appliances must include a recycle fee, and it must be on a separate row on an invoice. They can do this by setting up BOM's for the items, but the usability is a bit so-so because the "Explode BOM" function in the invoice only works on one row at a time, and they regularly have dozens of different items on an invoice (they sell to resellers a bunch of items at a time).
I'd like to modify the invoice window by adding a button "Explode BOM for all rows", which would basically just call the explode bom codeunit for each row. Now, I have never done any Navision programming, but I could figure out how to add the button, how to make it execute a codeunit, and I even found the original "explode BOM" code which works for one row (I have 20+ years of programming experience under my belt), but I can't figure out how to loop through all the rows in an invoice - nor do I know for sure if I can call the original function in a loop for each row.
So, after long explanation here comes the question: Can I do it, and if it's doable could someone point me towards an example of selecting and looping the rows of a given invoice?
Thank you very much in advance,
Jukkapalmu
Noob here, so go easy on me. I've a customer for whom I do mostly server and desktop support tasks, and they're using Financials 2.0 (yes, old, but it's working and they're on the cheap end of the scale so don't want to upgrade).
Now there's a new law here, stating that all household appliances must include a recycle fee, and it must be on a separate row on an invoice. They can do this by setting up BOM's for the items, but the usability is a bit so-so because the "Explode BOM" function in the invoice only works on one row at a time, and they regularly have dozens of different items on an invoice (they sell to resellers a bunch of items at a time).
I'd like to modify the invoice window by adding a button "Explode BOM for all rows", which would basically just call the explode bom codeunit for each row. Now, I have never done any Navision programming, but I could figure out how to add the button, how to make it execute a codeunit, and I even found the original "explode BOM" code which works for one row (I have 20+ years of programming experience under my belt), but I can't figure out how to loop through all the rows in an invoice - nor do I know for sure if I can call the original function in a loop for each row.
So, after long explanation here comes the question: Can I do it, and if it's doable could someone point me towards an example of selecting and looping the rows of a given invoice?
Thank you very much in advance,
Jukkapalmu
0
Comments
-
Going off the top of my head, but this should get you in the right direction.
SalesLine.SETRANGE("Document Type",SalesHeader."Document Type"); SalesLine.SETRANGE("Document No.",SalesHeader."No."); IF SalesLine.FIND('-') THEN BEGIN REPEAT Explode(SalesLine); UNTIL SalesLine.NEXT = 0; END;
If it's a button on the Order form, the Sales Header is the Source Table, so you'd use Rec instead of SalesHeader, or even leave out the record altogether.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