Create Add Bonus button under Sales Order
BrianBirk
Member Posts: 3
Hi Everyone.
Using Navision 4.0.
And I'm a complete newbie, sorry. If the question has been answered elsewhere then please don't yell at me :-) Just tell me the link, pretty please :-) :-)
I would like to create a button named 'Bonus' under Sales Order.
When the button is clicked the 'Unit Price excl. VAT' should be subtracted 10% (Just an example).
Ok, what I have done so far is the following.
Created the button 'Bonus' under Sales Order.
Linked that button to a function named 'AddBonus' under the form 'Sales Order Subform'.
Now I'm stucked as I have no idea how to enumerate through the lines of the current order to subtract the 10%.
I already know that this can be setup elsewhere in Navision, but I would like to know how to do it programmatically.
So actually to make it simple: How do I enumerate through the lines of the TableBox, so that:
"Unit Price" := "Unit Price" * 0.9;
is done on all lines instead of only the selected one?
Using Navision 4.0.
And I'm a complete newbie, sorry. If the question has been answered elsewhere then please don't yell at me :-) Just tell me the link, pretty please :-) :-)
I would like to create a button named 'Bonus' under Sales Order.
When the button is clicked the 'Unit Price excl. VAT' should be subtracted 10% (Just an example).
Ok, what I have done so far is the following.
Created the button 'Bonus' under Sales Order.
Linked that button to a function named 'AddBonus' under the form 'Sales Order Subform'.
Now I'm stucked as I have no idea how to enumerate through the lines of the current order to subtract the 10%.
I already know that this can be setup elsewhere in Navision, but I would like to know how to do it programmatically.
So actually to make it simple: How do I enumerate through the lines of the TableBox, so that:
"Unit Price" := "Unit Price" * 0.9;
is done on all lines instead of only the selected one?
0
Answers
-
I won't tell you exactly how to do it, but I will point you in the right direction. It'll be much more helpful since you are starting out.
First off, put your function in the Sales Header table, not the subform. That way you can call the function on any order from anywhere that the record is used.
Next, you need to figure out the relationship between the Sales Header and Sales Line table if you do not already know it. Take a look at the properties on the subform control from the main form and you will see how it is "linked".
Finally, search the forum or read the documentation about SETFILTER and REPEAT UNTIL loops. These are the two constructs you need in order to move through the appropriate lines.
Try these out, come up with your code, and if it doesn't work post it here and we can point you more in the right direction. Good luck.
0 -
mattrax, thank you very much for pointing me in the right direction.
Everything works perfectly now thanks to you :-)
I created a variable named salesline pointing to the report Sales Lines
and add this codesalesline.SETFILTER( "Document No.","No."); IF salesline.FINDSET THEN BEGIN REPEAT IF salesline."No." <> '' THEN MESSAGE(salesline.Description); UNTIL salesline.NEXT = 0; END;
Above was just for testing and it works like a charm.
Thanks again0 -
One thing you will want to add is a filter for the document type as well. You never know when you will have a Quote and an Order with the same number. In that case your code would do more than it should as it would process for both documents.0
-
as stated above also adding
salesline.SETFILTER( "Document Type","Document Type");
will help insure you are updating the proper order
You'll also have to throw in a
Salesline.modify;
to save your changes0
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
- 322 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
