I want to ask, is there some way, when I Insert/Modify record first to be Inserted/modified the record after that to be executed code in the OnInsert/OnМodify trigger.
In Navision Help for OnInsert/OnModify trigger is stated: “This trigger executes before the default insert/modify behavior is executed.”
I need this but in reverse order:
Default insert/modify behavior is executed.
INSERT/MODIFY trigger executes
I need this becouse I have code, in those triggers , wich should take in to acoount the New Record or the changes on the old Record
or maybe I should add this code in page Sales Price OnAfterGetRecord Trigger (in this trigger record is already inserted, right?), but I have read in forum that working with data in Pages/Forms is not recommended
I have table Special Products (that products are Items) . Price for every item from Special Products is taken from Sales Price table. But for one item there are many records in Sales Price. So I should get price from record with last starting date, Price Including Vat=True…and that is ok I done that.
But when is added new record in Sales Price for that Item, and if that record has newer Starting Date than existing ones, than Price in Special Product Table (for that Item) should be updated(with Unit Price from new record
You cannot change the triggers occurence, so forget about that
One solution is:
In Sales Price table, create a global variable and name it (for example) LatestPrice
In Sales Price table, create a global function and name it (for example) UpdateSpecialProducts with a local variable like (receivedPrice) and then inside the function write:
LatestPrice := receivedPrice;
On your Sales Price form, in OnValidate trigger of the field that your user inserts/modifys the sales price (or wherever that you think is suitable however after user enters the price), call the above function and pass the price (before calling this function you can also do whatever filters you have, to pass the right price) to Sales Price table
In your OnInsert/OnModify triggers of your Sales Price table just use the LatestPrice (remove all those lines that you had to find the price) and update your SpecialProducts table with LatestPrice value