I’ve encountered a situation where the system inserts records into a table without running the OnInsert trigger. To see this behavior create a new sales order and go to the first line of the order; don’t enter anything on this line instead use the down arrow key to move down several lines. After moving down several lines enter an item number onto the sales line. When you move off of this line a record is inserted into the Sales Line table along with records for the lines that were passed over with the down arrow key. The AutoSplitKey property insures that all records are properly numbered (10000, 20000, etc.), but the OnInsert trigger only seems to fire for the record where data is actually entered (i.e. the last line). Does anyone know of a trigger that can be used to detect the insertion of these additional lines? I’ve tested the OnInsert trigger on the table as well as the OnBeforePutRecord and OnInsertRecord on the form, but none of these seem to do the job.
Hi Jack - You are correct - Can you enlighten me/us why you are trying to accomplish this? A tip: Since it is the form, actually inserting the records, you might find one of the triggers on the FORM will catch it, but I am not sure.
I have developed an interface to another external system and I can’t rely on the line number field because of the possibility that data will be transferred to the other system, then the sales line is deleted, and another added in its place. The new sales line may have the same line number as the original but I need to be able to detect the fact that it is a “new” line. To solve this I added a new universal line number field to the sales line table with the AutoIncrement property set to TRUE. This way each time a sales line is added a unique line number is assigned to the record (a little care is required when copying documents and in a few other situations). However, in the situation I previously described where the user uses the down arrow to create new lines; the universal line number is not cleared and so the auto increment function does not happen and I end up with duplicate universal line numbers. I was hoping for a trigger where I could detect this situation and clear the universal line number before the record is actually inserted into the table. I checked the form triggers and didn’t find any that would do the job for me. There is, however, a form property called MultipleNewLines that is set to TRUE on the sales order subform. It is this property that allows the user to use the down arrow to advance past the next line. Setting this property to FALSE (the default value) keeps this from happening.
It is interesting to know that property “MultipleNewLines” creates line but doesn’t execute ONInsert. There may be reason why Navision did this.
Hmmmm - Sounds like an “interesting” feature. But how about processing the order in the Release Function. By doing that, you will accomplish the following:
- You know the user is done entering the order
- You have all lines in the database
- You now have full control over the lines in the order
Would that work for you? Just an idea?