Hello, when you sort a subform, you can’t insert or append a new line - because of the splitkey propertiy. You have to sort the lines again by the primary key, insert or append a new line and than sort it again. Does anyone know, how to change the line number according to the new sorting, so you don’t have to sort - resort -sort … the lines Thanks Michael
If you disable the splitkey functionality on the form and assign the primary key yourself, you can sort on whatever you wish. I’am not sure however if this is the way to go (you didn’t tell which table is involved).
It is about the sales lines.
Since the Autosplit does not generate a line no. till AFTER the insert, you can simply add code that basially checks the current key, and then if the currnet key is not “Documetn Type”,“Document No.”,“Line Mo.” then you can create your own line number. If you give it a value, Navision will continue to use the value you assign. I se this in comments, but it shold work in Sals Line just as well.
If you decide to assign your own line number then be careful of the changes in the behavior of dimensions. The function “CreateDim” uses the “Line No.” <> 0 test to see if dimensions should be inserted for this sales line. You might run into some strange order of events that causes dimensions to be inserted for a sales line that has not been committed to the database.
Hi Zarryn, Ive been doing this for a long time , and never seen this problem, can you let me know what issue you are having.
Hi David, Sorry if my post was confusing, but I am not having any problem. It was just an observation of a subsequent function that relies on “Line No.”. Here is how it could happen… The developer decides to assign a “Line No.” in the OnValidate of the Type field (not wise, but could happen). A user then enters Type and “No.” in the subform, which is delayed insert. The OnValidate of “No.” will insert dimensions into the document dimension table because a “Line No.” exists on the line. The user now panics and hits F4 because they chose the wrong “No.”. The line is deleted without calling the OnDelete trigger because it was never inserted. The dimensions remain in the Document Dimension table for a line that no longer exists… I apologize for my cryptic post. I should have said… ‘Be careful what trigger you choose to assign the line number, it could change the behavior of dimension related fields.’ Thank you for bringing this to my attention.
You should put the code in the OnInsert trigger. I can not see any reason for putting it in the type field, that would be just wrong.
David, My scenario was intended as a hypothetical possibility, not a recommendation. I agree that the assignment should be performed in the insert trigger.
OK, gotcha, I though you had a specific need to put the code on a field trigger instead of a table trigger.