Ok, so its somethign completely different. Take a look at how its done on the Item card, that is exactly what you want, i.e. “last modified by” just make it the same as “Last modified on”
I know Davis, sorry David, [:$], has told you how to achieve what you want, but! I think your logical understanding of Navision Development in this instance needs some help.
The first thing to note, is that you have created an unnecessary variable in this instance. You have created an instance of Sales Header record. But the thing to bear in mind with your code being on the “OnModfyRecord” trigger of the Sales Order form, is that the Pointer is on the record you wish to edit anyway. So to acheive what you wanted you would simply needed to have put
Next if your use of Init. Whilst this clears the record as need (and sets the defaults), it is also basically “Creating a record” with default values that has not been commited to the database (Which occurs on the call of Insert).
The normal call here would be reset.
But as explained by David on here you should be using the Table for this. The reason?, well, for each table you can have a multitude of forms, the Sales Header being a prime example, you have the Quote, Order, and Invoice forms just as an example. If you modify the form then you need to modify all other forms that are bound to that table. But it is highly unliekly that you will have two tables with the same data. And if you do your design is usually flawed and you need to go through the Database Normalisation process.
But again, if you are using the triggers on the Table then you need to undertstand that the “Pointer” is at the record calling the trigger, you do not need to go and get the record, and then modify it. There are instances when you do, but in the two examples above the pointer will be where you need it.