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?
0
Answers
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.
My Blog - nav.education
Everything works perfectly now thanks to you :-)
I created a variable named salesline pointing to the report Sales Lines
and add this code
Above was just for testing and it works like a charm.
Thanks again
My Blog - nav.education
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 changes
http://www.BiloBeauty.com
http://www.autismspeaks.org