Sales Line creating new lines and assigning new line no.

dimitris
dimitris Member Posts: 17
Hallo Everybody
I have a problem in the sales line table. I wrote some code in form 46 (Sales Order Subform) that does the following: If the type is item and the item no exists in a custom table that i created then i would like to automatic insert some new lines in the Sales Line table, the number of lines depends on how many times the item no. exists in the custom table. Every new line stands for a new item with a specific amount of quantity and a value. My problem has to do with the Line No. of Sales Line. As I observed the line no. is zero until you fill the Quantity field then it increments by 10000. Where can I find the piece of code that does this? I incremented every new line by 10000 in order to insert my new lines, but I do not know what to do if someone puts a record between 2 existing lines (e.g 10000 and 20000) the new line no becomes 15000. then i can not increment by 10000 because it would destroy my order. Any ideas?
Also i noticed that sometimes i need to change to the next record in order to the line no to be assigned a new number. That makes things more complicated.
I would appreciate any help

Comments

  • Savatage
    Savatage Member Posts: 7,142
    look at how the item's extended text works
  • Miklos_Hollender
    Miklos_Hollender Member Posts: 1,629
    It's not code, it's the AutoSplitKey property of the form itself... yeah, really, not joking, I was quite surprised when I found it :)

    Just number your lines by 10000 and when users insert new records the form with automagically halve the key each time (like, 15000, 12250, and so on).
  • dimitris
    dimitris Member Posts: 17
    changing the autosplitkey property to no, whenever a new record is inserted the line no remains 0, which creates an error. not good I suppose. What do you mean by saying the item's extended text?
  • Miklos_Hollender
    Miklos_Hollender Member Posts: 1,629
    But why do you want to change it? It works so that you generate the lines and the user can insert lines before, after, or within your lines. What do you want to do? Disallow inserting within your lines or what?
  • lessi
    lessi Member Posts: 33
    Not a good idea to change this property.

    Extended text is a functionnality you will find in the Menu of Item Card.

    It permits to automatically add lines of text in document.
  • Miklos_Hollender
    Miklos_Hollender Member Posts: 1,629
    Anyway, I think you give a new Line No. from the OnInsert trigger (FIND(+)-ing the last record and increasing it) if you really want, but I don't really understand what you are trying to accomplish.